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!

count the value in a iif conditional expression

Status
Not open for further replies.

julsie

Programmer
Nov 30, 1999
3
US
i need to count the value contained in several records for a specific condition. what's the best approach??
 
Try<br>
<br>
SELECT count(*)<br>
FROM your_table<br>
WHERE your_condition_exists;
 
I have it counting for a qty field which then sums by certain levels. I'm wondering a count (iif) statment is required?
 
Could you provide a small sample of data and the output you desire? This would make it much easier to work on a solution.
 
fields are qty/condition/location<br>
<br>
qty can be any number (5,4,3,2,1), condition is either A or F, location is one of wh, proj, prog<br>
<br>
if i have several records that are the condition A i want to see the count of the qty and sum it by location????
 
OK, let's try this:<br>
<br>
SELECT location, count(qty), sum(qty)<br>
FROM your_table<br>
WHERE condition = 'A'<br>
GROUP BY location;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top