Ebot Tabi
Ebot Tabi

Reputation: 92

Which is the best approach to translates the results of a sql query directly to the X and Y axis of a chart

I wish to find out the appropriate approaches to translates the results of a sql query directly to the X and Y axis of a chart, when you have multiple columns in the statement. for example
SELECT city,country,count(*) FROM beer group by country having count(*) > 100 order by 2 desc how should i handle this.

Thanks.

Upvotes: 0

Views: 53

Answers (1)

AgRizzo
AgRizzo

Reputation: 5271

In your case, I think you just want to take your city and country columns and combine them, like this:

SELECT CONCAT(city , ', ', country) AS x_axis, COUNT(*) as y_axis
FROM beer
GROUP BY city, country
HAVING COUNT(*) > 100
ORDER BY country, city;

Upvotes: 1

Related Questions