September 30, 2008 at 10:47 pm
I have a table with 2 columns: AgrNo and RowFlag. RowFlag can have 2 values ie 'Y' or 'N'. I would like to count the number the total 'y' and 'N' for a corresponding AgrNo.
Resultant set will have 3 columns: Agrno, CountOf(Y) and CountOf(N).
countOf(Y) : will have the count of RowFlag with value as 'y' for an AgrNo
countOf(N) : will have the count of RowFlag with value as 'N' for an AgrNo
any suggestions how to go about it
October 1, 2008 at 12:24 am
SELECTagrNo,
SUM(CASE WHEN rowFlag = 'Y' THEN 1 ELSE 0 END) AS countOfY,
SUM(CASE WHEN rowFlag = 'N' THEN 1 ELSE 0 END) AS countOfN
FROMTable1
GROUP BYagrNo
N 56°04'39.16"
E 12°55'05.25"
October 1, 2008 at 3:51 am
the suggestion helped. Thanks a ton.
Viewing 3 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy