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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Return count of order items with OrderID in query of orders

Status
Not open for further replies.

Amesville

Programmer
Oct 10, 2011
93
US
Hi Folks

May be a simple question but I can't seem to figure this out -

I want to return a query of open orders and on each row show a count of the order items for the order.

I'm guessing that a sub-query would be involved here but I can't seem to hit on the proper structure of the command to do this?

Hoping someone can help.

Craig

 
Something like....

Code:
SELECT O.ORDER_ID, O.OTHER_STUFF,
([blue]SELECT COUNT(*) FROM ORDER_ITEMS OI
WHERE OI.ORDER_ID = O.ORDER_ID[/blue]) AS NO_OF_ITEMS
FROM ORDERS O


---- Andy

There is a great need for a sarcasm font.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top