Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 SQL Querry

Author  Topic 

asrijsiraj
Starting Member

1 Post

Posted - 2010-03-24 : 11:47:30
cItem______dDate_______iAmount
___A____23/03/10 9:30________2___
___B____23/03/10 9:42________6___
___A____23/03/10 9:46________8___
___A____24/03/10 10:31_______4___
___B____24/03/10 10:35_______9___
___A____24/03/10 10:44_______1___


i want to fetch the record from the above table is the cItem, iAmount as follows:

cItem_______iAmount
___A____________10___
___B_____________6___


the item and the total amount salled on a the day 23/03/10.

pls help me to get the result

thanx in advanced.


msmasrij

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-03-24 : 11:52:28
[code]SELECT cItem,SUM(iAmount) AS iAmount
FROM Table
WHERE dDate >= @YourDate
AND dDate < @YourDate + 1
GROUP BY cItem,DATEADD(dd,DATEDIFF(dd,0,dDate),0)
[/code]

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2010-03-24 : 11:54:08
select
cItem,
sum(iAmount) as iAmount
from Table
where dDate >= '20100323'
and dDate < '20100324'
group by cItem


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page
   

- Advertisement -