Help I am stuck....bet you havent heard that before...anyway to the issue.
I am trying to retrieve a row per case out of my database.
Basicially I am trying to find the first code for every caseheader_rsn in a table....
select CASEHEADER.CASEHEADER_RSN,
CASEHISTORY.CODE,
CASEHISTORY.SYSTEMDATE
from caseheader
inner join casehistory
on caseheader.caseheader_rsn = casehistory.caseheader_rsn
inner join caseevent
on casehistory.caseheader_rsn = caseevent.caseheader_rsn
WHERE CODE IN ('2010', '2004', '2014', '2017', '1458')
AND CASEHEADER.CASEHEADER_RSN = 1777
THE RESULTS SHOW AS
1777 2014 2009-07-30 11:37:10.763
1777 2010 2010-11-02 14:45:31.973
1777 1458 2010-12-22 12:35:26.357
In the query above I have added a where clause to a specific CaseHeader_rsn which shows three rows for one caseheader_rsn. I want to return the the first one, not just for one caseheader_rsn but for all the caseheader_rsn I have in the table.
Hope this makes sense. What I want to get to is:
1777 2014 2009-07-30 11:37:10.763
1862 2010 2010-11-02 14:45:31.973
1928 1458 2010-12-22 12:35:26.357
and so on.
Help me please.
I am trying to retrieve a row per case out of my database.
Basicially I am trying to find the first code for every caseheader_rsn in a table....
select CASEHEADER.CASEHEADER_RSN,
CASEHISTORY.CODE,
CASEHISTORY.SYSTEMDATE
from caseheader
inner join casehistory
on caseheader.caseheader_rsn = casehistory.caseheader_rsn
inner join caseevent
on casehistory.caseheader_rsn = caseevent.caseheader_rsn
WHERE CODE IN ('2010', '2004', '2014', '2017', '1458')
AND CASEHEADER.CASEHEADER_RSN = 1777
THE RESULTS SHOW AS
1777 2014 2009-07-30 11:37:10.763
1777 2010 2010-11-02 14:45:31.973
1777 1458 2010-12-22 12:35:26.357
In the query above I have added a where clause to a specific CaseHeader_rsn which shows three rows for one caseheader_rsn. I want to return the the first one, not just for one caseheader_rsn but for all the caseheader_rsn I have in the table.
Hope this makes sense. What I want to get to is:
1777 2014 2009-07-30 11:37:10.763
1862 2010 2010-11-02 14:45:31.973
1928 1458 2010-12-22 12:35:26.357
and so on.
Help me please.