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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can a simple query achieve this result? 1

Status
Not open for further replies.

yehong

Programmer
Sep 22, 2003
291
US
I need to write a simple query that achieves following results.

Data in a table say Table1.

EmpID StartDate CurrentStatus Grade
10001 04/01/2006 A Null
10001 05/01/2006 Null G-A

The result set that I expect should look like following in one row:
EmpID Year CurrentStatus Grade
10001 2006 A G-A

Thanks,
 
Code:
SELECT EmpId, YEAR(StartDate)        AS [Year],
       MAX(ISNULL(CurrentStatus,[])) AS CurrentStatus,
       MAX(ISNULL(Grade,[]))         AS Grade
FROM Table1
GROUP BY EmpId, YEAR(StartDate)
(not tested)

Borislav Borissov
 
Thanks it was really a very simple query. I modifed my query and it worked like a charm.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top