🔒 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
  • 440
    Views
  • 3
    Participants
Last reply from:
PHC-SUIYOBI

Online now

Members online
997
Guests online
1,385
Total visitors
2,382

Forum statistics

Threads
2,276,208
Posts
28,968,320
Members
1,231,166
Latest member
williamfreede
Back
Top