我大家,尽管阅读了许多文档和网页,但我不知道如何使我的代码工作。
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 吗?但是如何?