简体   繁体   中英

MySQL:-Displaying results in a single row

I have a query which is working fine but the results are displaying in multiple columns. 查询结果。

But I want the results into a single row like

closed Open Cancelled
  2      1      3

The GROUP BY clause will return one row for each value grouped by. Since you have three material_status values you are getting three rows returned. Simply remove that clause and you will get one line in the results since all of your columns are aggregate.

SELECT SUM...
FROM purchase_order

The ORDER BY clause is also not necessary since you are only returning one row.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM