on 09-09-2015 6:44 PM
Hi, I have table with 3 fields
COL1, COL2 and COL3
COL3 having values 1 or 0 for all the records in a table.
Suppose COL2 having value AB which is having 1 and 0 as values of COL3 that means 2 records. from these 2 records i need to retrieve one record based on COL3 value.
in this case i need to PIck where the COL3 =1
suppose the COL2 having only one value with COL3 having 0 then i need to consider that one
Please help me how to get this in sql
Hi Kalyan,
Is this what you want?
SELECT * FROM TABLE WHERE (COL2, COL3) IN (SELECT COL2, MAX(COL3) FROM TABLE GROUP BY COL2);
Regards,
Chandu.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
76 | |
9 | |
8 | |
7 | |
6 | |
5 | |
5 | |
5 | |
5 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.