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

Method to Count Number of Returned Rows 1

Status
Not open for further replies.

Signit

MIS
Oct 17, 2003
114
US
The following query returns 4 rows of data. I would like to write a query that will count those rows. ie if 4 rows are returned I want to simply have a single row that says 4. Would this require a view? Thanks for your help in advance!

Code:
SELECT recipeID, count(ingredientID) AS N
FROM recipeIngredients
WHERE (ingredientID='ing011' OR ingredientID='ing015' OR ingredientID='ing032')
GROUP BY recipeID;
 
Something like this ?
SELECT COUNT(DISTINCT recipeID) AS NRows
FROM recipeIngredients
WHERE (ingredientID='ing011' OR ingredientID='ing015' OR ingredientID='ing032');

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top