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 |
|
imughal
Posting Yak Master
192 Posts |
Posted - 2004-06-25 : 07:20:24
|
| hi,i want to get amount by each category. my table structure is1.order [orderid, total (varchar)]2.items [orderid,productid, ]3.products [productid, categoryid]4. categories [categoryid,categoryname]the result should be like categoryid categoryname totalamount 1 abc 1000 2 xyz 5000regards,im |
|
|
Wanderer
Master Smack Fu Yak Hacker
1168 Posts |
Posted - 2004-06-25 : 07:51:28
|
| select c.categoryid,c.categoryname,sum(cast ((o.total) as dec (10,2)) ) as totalamountfrom [order] o inner joinitems i on o.orderid = i.orderidinner join products pon i.productid = p.productidinner join category con p.categoryid = c.categoryidgroup by c.categoryid,c.categoryname*##* *##* *##* *##* Chaos, Disorder and Panic ... my work is done here! |
 |
|
|
|
|
|