sath350163
asked on
Query to fetch rows with matching values for just few columns column as a single row
Hello,
I have a table with rows having same id and code value, but different Effective date.
My query needs to return only 2 rows, one for 1 basic, and another for 1 exclusive.
Result should be like:
DISTINCT would not work as the Effective date is different between the two records with Id=1 and Code = 'Basic'.
Thanks!
I have a table with rows having same id and code value, but different Effective date.
Id Code EffectiveDate cost
1 basic 01-jan-2010 5.00
1 basic 06-feb-2011 5.00
1 exclusive 09-aug-2012 15.00
My query needs to return only 2 rows, one for 1 basic, and another for 1 exclusive.
Result should be like:
Id Code cost
1 Basic 5.00
1 Exclusive 15.00
DISTINCT would not work as the Effective date is different between the two records with Id=1 and Code = 'Basic'.
Thanks!
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
from YourTable