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

Trending Topics

Online now

Members online
1,088
Guests online
1,893
Total visitors
2,981

Forum statistics

Threads
2,286,694
Posts
29,039,693
Members
1,217,129
Latest member
damnation21
Back
Top