有人可以告訴我如何將這些查詢嵌套到一個完整的查詢中嗎?現在,我一次只運行一個(最多10個),但我想學習如何在單個鏡頭中運行此查詢。如何嵌套多個SQL查詢?
Dim queryString1 As String =
"SELECT EMPLOYEE_NAME, AVG(EFFICIENCY_YIELD) AS YIELD
FROM dbo.APE_BUSDRIVER_MAIN
WHERE APE_AREA_OBJID = " & lblAreaOBJID.Text & "
AND ACTIVE = 1
GROUP BY EMPLOYEE_NAME ORDER BY YIELD " & lblSortOrder.Text & ""
Dim queryString2 As String =
"SELECT EMPLOYEE_NAME, AVG(EFFICIENCY_YIELD) AS YIELD
FROM dbo.APE_BUSDRIVER_MAIN
WHERE APE_AREA_OBJID = " & lblAreaOBJID.Text & "
AND ACTIVE = 1
AND EMPLOYEE_NAME <> '" & LblStckRnk1.Text & "'
GROUP BY EMPLOYEE_NAME
ORDER BY YIELD " & lblSortOrder.Text & ""
Dim queryString3 As String =
"SELECT EMPLOYEE_NAME, AVG(EFFICIENCY_YIELD) AS YIELD
FROM dbo.APE_BUSDRIVER_MAIN
WHERE APE_AREA_OBJID = " & lblAreaOBJID.Text & "
AND ACTIVE = 1
AND EMPLOYEE_NAME <> '" & LblStckRnk1.Text & "'
AND EMPLOYEE_NAME <> '" & LblStckRnk2.Text & "'
GROUP BY EMPLOYEE_NAME
ORDER BY YIELD " & lblSortOrder.Text & ""
OK涼爽。我會嘗試的。謝謝! –
問題:如何生成第二個聯合查詢的itemID?我想如果我使用CType(Reader.Item(2),字符串)我將能夠獲得第二個員工,但即時通訊「索引超出數組的界限。」錯誤 –
ItemID不是結果集的一部分。您需要將其添加到三個查詢中的每一個。請記住,Reader.Item(2)引用SELECT語句中的第三項(並且只指定了兩個項目)。 – tgolisch