Quantcast
Channel: MySQL: Convert Column Values to Headers with Totals - Stack Overflow
Browsing latest articles
Browse All 2 View Live

Answer by juergen d for MySQL: Convert Column Values to Headers with Totals

select dogType, sum(case when agLevel = 1 then total else 0 end) as ag1, sum(case when agLevel = 2 then total else 0 end) as ag2, sum(case when agLevel = 3 then total else 0 end) as ag3 from dogs group...

View Article



MySQL: Convert Column Values to Headers with Totals

I have a MySQL table 'dogs' structured like so: AgLevel DogType Total 1 1 10 2 1 29 3 1 30 1 2 20 2 2 14 3 2 28 So this says there are 10 dogs of type 1 with an aglevel of 1, 29 dogs of type 1 with an...

View Article
Browsing latest articles
Browse All 2 View Live




Latest Images