Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/191.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sql 根据列车编号系列选择一个不同的RowId_Sql_Excel_Vba - Fatal编程技术网

Sql 根据列车编号系列选择一个不同的RowId

Sql 根据列车编号系列选择一个不同的RowId,sql,excel,vba,Sql,Excel,Vba,我有一张excel(2010)表格,上面有如下数据: trainnumber RowId 2 0 2 1 2 3 4 4 4 5 4 6 RowId 0 4 我想要一张这样的清单: trainnumber RowId 2 0 2 1 2 3 4 4 4 5 4

我有一张excel(2010)表格,上面有如下数据:

trainnumber RowId
2           0
2           1
2           3
4           4
4           5
4           6
RowId
0
4
我想要一张这样的清单:

trainnumber RowId
2           0
2           1
2           3
4           4
4           5
4           6
RowId
0
4
表示每个车次序列的第一个RowId

我曾尝试构建一个SELECT语句,但in不起作用。(我讨厌SQL lol)

它告诉我subselect中存在语法错误,因此我尝试使用sheetname,但它给出了相同的错误:

sSQL = "select " & _
              "RowId, " & _
              "(select top 1 trainnumber from @[Conversion$] t2 where t.RowId = t2.RowId order by RowId), " & _
              "from @[Conversion$] t " & _
              "group by RowId"

如果您希望每个都是第一个,您可以获得
min

Select min(rowID)
from youtable
group by trainer_number
;

@如果您需要
VBA
请提供一些mroe样本,例如至少3个不同的
培训师编号
。。因此,我们可以看到数据模式:)谢谢,这正是我需要的。:)