我有3個表:SQL - 選擇列中多次
系統的系統信息
WorkstationID
WorkstationName
製造商
OS
SoftwareInfo
WorkstationID
SoftwareID
SoftwareList
SoftwareID
SoftwareName
SoftwareVersion
每個workstationID有大約20 SoftwareID行(閱讀器,閃存,Java等)我想輸出類似於此:
WorkstationID | OS | Manufacturer| Reader Version | Flash Version | Java Version
Desktop01 | W7 | Lenovo | 11.0.7 | 14.X | 8.X
我無法弄清楚如何查詢SoftwareList多次和過濾器每查詢,以便它只返回相對於當前WorkstationID的SoftwareVersion。
這是我的代碼到目前爲止,這將不執行:
select
systeminfo.WorkstationName,
systeminfo.OS,
systeminfo.Manufacturer,
(Select SoftwareList.SoftwareVersion
from systeminfo
join softwareinfo on systeminfo.workstationid = softwareInfo.workstationID
JOIN SoftwareList on softwareinfo.softwareid = softwarelist.softwareid
where SoftwareName = 'Reader'
and softwareinfo.workstationid = systeminfo.workstationid) as "Reader"
from
systeminfo
join softwareinfo on systeminfo.workstationid = softwareInfo.workstationID
JOIN SoftwareList on softwareinfo.softwareid = softwarelist.softwareid
使用透視功能。順便說一句,這是哪個DB? –
我會研究一下。我正在運行PostgreSQL。 – ChemistryTruck
您的查詢引用SoftwareInfo.FILEVERSION,但我沒有在SoftwareInfo表中看到FILEVERSION? – Greg