By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,265 Members | 1,343 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,265 IT Pros & Developers. It's quick & easy.

Selecting seperate fields from file - each based on different criteria

P: 1
We have a file with grade fields - each with a 'status' field which we would like to use as criteria for adding the the grade fields togather.
(ie. if status field for grade1 is 'A', add to sum, else bypass)

Thanks for your help
Oct 16 '09 #1
Share this Question
Share on Google+
1 Reply

Expert 100+
P: 1,134
use case when

for example, this will return the number of records that have Field1=0
Expand|Select|Wrap|Line Numbers
  1. select sum(case when Field1=0 then 1 else 0 end as result
  2. From TheTable
There are better ways to do that.
It servers to illustrate CASE WHEN
Oct 19 '09 #2

Post your reply

Sign in to post your reply or Sign up for a free account.