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.
| 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 resultthanx 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 iAmountFROM TableWHERE dDate >= @YourDateAND dDate < @YourDate + 1GROUP BY cItem,DATEADD(dd,DATEDIFF(dd,0,dDate),0)[/code]------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2010-03-24 : 11:54:08
|
selectcItem,sum(iAmount) as iAmountfrom Tablewhere 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. |
 |
|
|
|
|
|