Mysql查詢結果列並列

需求:

在實際數據庫查詢中可能需要將多個查詢結果列並列顯示。將查詢結果並列成一張表。用GROUP_CONCAT關鍵字來實現查詢結果的並列。

SELECT COUNT(*) wpcount,(SELECT GROUP_CONCAT(sub1.lpcount) FROM(SELECT COUNT(*) lpcount  FROM limit_power_for_daily WHERE lp_lp_rate_fd>0.05 and lp_year=2019 and lp_month=7)sub1) lpcount,
(SELECT GROUP_CONCAT(sub2.npcount) FROM(SELECT COUNT(*) npcount FROM limit_power_for_daily WHERE ne_lp_rate_fd>0.05 and lp_year=2019 and lp_month=7)sub2) npcount
 FROM limit_power_for_daily WHERE wp_lp_rate_fd>0.1 and lp_year=2019 and lp_month=7

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章