What's new

Help Get percentage of column total mysql

DarkResurrection

Eternal Poster
Established
Joined
May 28, 2016
Posts
806
Solutions
1
Reaction
139
Points
291
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.JPG

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.png


to this po,
1650282123071.png


Sana may makatulong po, maraming salamat po.
 

Attachments

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
 

Similar threads

Back
Top