I have a excel(2010) sheet with data like this:
trainnumber RowId
2 0
2 1
2 3
4 4
4 5
4 6
And I want a list like this:
RowId
0
4
Meaning the first RowId of each of the trainnumber series
I've tried build a SELECT statement, but in doesn't work.(I suck at SQL lol)
sSQL = "select " & _
"RowId, " & _
"(select top 1 trainnumber from @t t2 where t.RowId = t2.RowId order by RowId), " & _
"from @t t " & _
"group by RowId"
It tells me, that there's an Syntax Error in the subselect, so I tried the used the sheetname, but it gives me the same error:
sSQL = "select " & _
"RowId, " & _
"(select top 1 trainnumber from @[Conversion$] t2 where t.RowId = t2.RowId order by RowId), " & _
"from @[Conversion$] t " & _
"group by RowId"
If you want first for each , you can get the
min
: