儘管我閱讀了很多文檔和網頁,但我仍然沒有如何讓代碼工作。SQL錯誤代碼:1242 /如何在表中轉換我的代碼?
select
(select count(*) from toto where (ddate between '2012-01-01' and '2012-12-31') group by produit) "2012",
(select count(*) from toto where (ddate between '2011-01-01' and '2011-12-31') group by produit) '2011',
(select count(*) from toto where (ddate between '2010-01-01' and '2010-12-31') group by produit) '2010'
我有一個SQL錯誤代碼:1242消息。是的,這是正常的,因爲我確實有超過1行返回。
我該如何處理?隨着使用PIVOT?但是如何?
的數據庫您使用的?無論如何,請將該標籤添加到問題中(例如,mysql,sql-server,oracle等) – Bohemian