August 18, 2003 at 7:01 am
I have a table with three columns, Item_no, Date, Qty.
what I want to do is, select on this table but if there is for example 3 records with the same Item_no and Date, I would like it to add the qty up for these, and just give me one record back with the combined total. There are 100 of different records in the table but only 10 percent have duplicate item_no and Date and different Qty.
IF anyone can help I will be glad to give more info
Thanks in advance
Paul East
August 18, 2003 at 7:17 am
Hi Paul,
quote:
I have a table with three columns, Item_no, Date, Qty.what I want to do is, select on this table but if there is for example 3 records with the same Item_no and Date, I would like it to add the qty up for these, and just give me one record back with the combined total. There are 100 of different records in the table but only 10 percent have duplicate item_no and Date and different Qty.
do you want something like
SELECT Item_no, SUM(Qty) AS blabla
GROUP BY Item_No ?
Cheers,
Frank
--
Frank Kalis
Microsoft SQL Server MVP
Webmaster: http://www.insidesql.org/blogs
My blog: http://www.insidesql.org/blogs/frankkalis/[/url]
August 18, 2003 at 7:20 am
And add the date to that solution to yield
SELECT item_no, date, sum(qty)
FROM table
GROUP BY item_no, date
August 18, 2003 at 7:28 am
quote:
And add the date to that solution to yield
SELECT item_no, date, sum(qty)
FROM table
GROUP BY item_no, date
err, yes!
Cheers,
Frank
--
Frank Kalis
Microsoft SQL Server MVP
Webmaster: http://www.insidesql.org/blogs
My blog: http://www.insidesql.org/blogs/frankkalis/[/url]
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply