Hello,
I need to return the first row of data grouped by the first field (Visit ID) in multi-column table:
VisitID AdmitDate Unit Room OrderCode
001041 2014-08-01 2E 202 SWCC
001041 2014-08-01 2E 202 NULL
006811 2014-08-01 2E 204 SWCC
008815 2014-08-01 2E 206 NULL
004895 2014-08-01 2E 207 SWFA
004895 2014-08-01 2E 207 SWCC
004895 2014-08-01 2E 207 NULL
To return:
001041 2014-08-01 2E 202 SWCC
006811 2014-08-01 2E 204 SWCC
008815 2014-08-01 2E 206 NULL
004895 2014-08-01 2E 207 SWFA
I currently have a group by clause with all field names; and have tried max on the OrderCode in the select that doesn't work, and FIRST isn't recognized in SSL server. Do I need a subquery (if so, how as I'm newer to writing SQL) or what is another solution? Thank you.