我收到了一些重複的case case語句。來自Case語句的冗餘行並加入SQL Server
如何避免使用子查詢?
SELECT
[S].[TicketNbr] AS 'Ticket Nbr'
, [S].[status_description] AS 'Status'
, (CASE WHEN [A].OldValue_Text = 'Service Desk' THEN 1 ELSE 0 END) AS 'Moved from Old Board?' END) AS 'Moved from Old Board?'
FROM [Service] AS [S]
LEFT OUTER JOIN [Audit] AS [A]
ON [A].[TicketNbr]=[S].[TicketNbr]
GROUP BY [S].[TicketNbr]
, [S].[status_description]
,(CASE WHEN [A].OldValue_Text = 'Service Desk' THEN 1 ELSE 0 END)
注意我只想用1
是你確定你應該在這裏使用外連接?你想用這個查詢做什麼? – MBurnham