C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !




SQL SERVER


Posted Date: 30 Aug 2008      Total Responses: 1

Posted By: pallavi satish punekar       Member Level: Gold     Points: 1


i have a problem in SQL SERVER 2005 isnull function


i have query lk this


select isnull(sum(a.Totalreceipt),0)
from GRNrmdayconsolidated a
where convert(varchar(10),a.ReceiptDate,120)='2008-008-28'
group by a.itemcode,a.vendorid


If there r no records with this date it wil retum nothing
bt same query if i remove the group by clause
select isnull(sum(a.Totalreceipt),0)
from GRNrmdayconsolidated a
where convert(varchar(10),a.ReceiptDate,120)='2008-008-28'


when there is no record it wil return 0

again in the same query if i remove the sum
select isnull((a.Totalreceipt),0)
from GRNrmdayconsolidated a
where convert(varchar(10),a.ReceiptDate,120)='2008-008-28'


It wil nt return any thing


What is the problem in frist and last query and how isnull function works




Responses

Author: http://venkattechnicalblog.blogspot.com/    31 Aug 2008Member Level: DiamondRating:     Points: 6
I am not clear about your needs. Any way, let me explain some key concepts in your query,
Below query will fetch the sum of your receipt on the specific date.
If the sum value is null , then 0 will be replaced, in the below query you will get multiple rows grouped under itemcode and vendor id

select isnull(sum(a.Totalreceipt),0)
from GRNrmdayconsolidated a
where convert(varchar(10),a.ReceiptDate,120)='2008-008-28'
group by a.itemcode,a.vendorid


In this code you will get a single row with sum of the values on the specific date.


select isnull(sum(a.Totalreceipt),0)
from GRNrmdayconsolidated a
where convert(varchar(10),a.ReceiptDate,120)='2008-008-28'


Here you will get the exact data on the specific date.


select isnull((a.Totalreceipt),0)
from GRNrmdayconsolidated a
where convert(varchar(10),a.ReceiptDate,120)='2008-008-28'


Regards,
Venkatesan prabu .J
http://venkattechnicalblog.blogspot.com/



Post Reply
You must Sign In to post a response.
Next : How to make schedular in Ms-Sql
Previous : New to sql
Return to Discussion Forum
Post New Message
Category: SQL Server

Related Messages



dotNet Slackers   BizTalk Adaptors    Web Design

silicone halloween masks

Contact Us    Privacy Policy    Terms Of Use