我試圖運行以下查詢(針對Foodmart 2000),它在MySQL上運行良好。在SQL Server 2005上,我得到的只是一條「附近的語法錯誤」消息。將MySQL轉換爲SQL Server
SELECT * FROM ((SELECT COUNT(state_province) AS 'WA'
FROM customer c1
WHERE c1.state_province LIKE 'WA'
GROUP BY c1.state_province) as t1,
(SELECT COUNT(state_province) AS 'OR'
FROM customer c1
WHERE c1.state_province LIKE 'OR'
GROUP BY c1.state_province) as t2,
(SELECT COUNT(state_province) AS 'CA'
FROM customer c1
WHERE c1.state_province LIKE 'CA'
GROUP BY c1.state_province) as t3);
究竟是什麼導致了這個問題?
我認爲你應該爲主表提供一個別名。 'SELECT * FROM(.....)tbl' – arunes
什麼是輸入以及該查詢的預期輸出是什麼? – Alex