Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Troubloe Grouping

Status
Not open for further replies.

civilwarjunky

IS-IT--Management
Aug 26, 2004
19
0
0
US
I am trying to group them by item# and total each item number. Example D19 = 1200 and do this for each item.

select soline.Invtid as 'Item #',soline.descr as 'Description',
soline.qtyord as 'QTY',soline.status,
sum(soline.qtyord)
from soline
where status='o'
Group by soline.Invtid,
soline.descr,
soline.qtyord,
soline.status
order by invtid
 

Just at a quick glance I think you need to change your group, order and sum to use the names that you gave the fields in the select statement.

select soline.Invtid as 'Item #',soline.descr as 'Description',
soline.qtyord as 'QTY',soline.status,
sum(QTY)
from soline
where status='o'
Group by Item #,
Description,
Quantity,
soline.status
order by Item #
 
Sorry leishad, that's not correct. You have to use the actual expressions from the select clause (although you can group by expressions which aren't in the select clause as well).

civilwarjunky,

are you getting an error message? Give some sample source and queried data.
 
Apologies for a wrong answer, I know better --- I did run a duplicate of this query (in query analyzer) against my own similar data and it worked just fine so clearly more information will be required.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top