I have a very simple question that’s kicking my ass.
CUSTNMBR | first_date | SOPNUMBE
----------------------------------------
3344771005 | 2012-05-03 | 334471961748
3344771005 | 2012-04-04 | 334476873726
In the above table i want to return the earliest date along with the custnumbr and sopnumbe so it’ll look like this
3344771005 | 2012-04-04 | 334476873726
I used this
Select a.CUSTNMBR, min(a.Tax_Date) as first_date, a.SOPNUMBE
from SOP30200 as a
where a.CUSTNMBR = '3344771005'
Group by a.CUSTNMBR, a.SOPNUMBE
but it returns all variables and if I knock off the a.sopnumbe in group it errors out.
Try this: