0
我被計數列上的mysql ROLLUP卡住了。你能指導我嗎?與計數的mysql彙總
我寫下面的MySQL查詢
查詢:
SELECT (SELECT store.StoreName from store
WHERE store.storeOwnerId=redeem.StoreNo)
AS CompanyName,
(SELECT mscheme.SchemeName from mscheme
WHERE mscheme.SchemeNo = redeem.SchemeNo)
AS SchemeName,
count(*) AS Count
FROM kirana_app.redeem GROUP BY redeem.SchemeNo
ORDER BY CompanyName;
** **輸出
CompanyName,SchemeName, Count
'Dwarkesh', 'September-saffola', '25'
'Dwarkesh', 'September-Tea', '20'
'Nitin stores', 'Testing Scheme', '1'
'Nitin stores', 'September-Parle', '63'
我需要與計數列捲起像
輸出如:
CompanyName,SchemeName, Count
'Dwarkesh', 'September-saffola', '25'
'Dwarkesh', 'September-Tea', '20'
**Dwarkesh', NULL, '45'**
'Nitin stores', 'Testing Scheme', '1'
'Nitin stores', 'September-Parle', '63'
**'Nitin stores', NULL, '64**'
您是否嘗試過「GROUP BY CompanyName」? – JazyK 2014-09-24 05:58:38