🔒 Closed Get percentage of column total mysql

Status
Not open for further replies.

PHC-SUIYOBI

Eternal Poster
Good day po, baka may nakakaalam po jan kung paano kuhanin yung percentage of column total po based sa sql statement ko po

Code:
SELECT Product, ROUND(SUM(Revenue),2) AS Revenue
FROM dataset
GROUP BY Product;

then ito yung output nung sql statement ko,

dbdb.webp
Then ang gusto ko po sana is ganito yung magiging output niya,

from this, (ni-"show values as" ko po siya as "%of Column Total" po)
1650282088863.webp

to this po,
1650282123071.webp

Sana may makatulong po, maraming salamat po.
 
Try mo ito kung gagana:

Code:
SELECT Product, ROUND(SUM(Revenue),2)*100/t.s AS Revenue
FROM dataset
GROUP BY Product
CROSS JOIN (SELECT SUM(Revenue) AS s FROM dataset) t
 
Status
Not open for further replies.

About this Thread

  • 3
    Replies
  • 455
    Views
  • 3
    Participants
Last reply from:
PHC-SUIYOBI

Trending Topics

Online now

Members online
1,007
Guests online
3,169
Total visitors
4,176

Forum statistics

Threads
2,332,134
Posts
29,262,828
Members
1,146,081
Latest member
famousff66
Back
Top