westy

SQL Query for multi series line chart

Recommended Posts

Hi there, let me first say what a great product!

 

 

 

I want to create a multi series line graph from a table in a mysql database.

 

 

 

I want to plot a line for each unit, of the results over time.

 

 

 

So the category should be time, and the each unit_id should be a series.

 

 

 

I have the following table in mysql:

 

 

 

unit_id | time | result

 

A | 1 | 10

 

A | 2 | 12

 

A | 3 | 15

 

A | 4 | 16

 

B | 1 | 5

 

B | 2 | 7

 

B | 3 | 9

 

B | 4 | 10

 

C | 1 | 16

 

C | 2 | 18

 

C | 3 | 20

 

C | 4 | 22

 

 

 

 

 

How should my SQL query(s) look to get the data appropriate for a multi series fusionchart line chart?

 

 

 

Should I do one query for category as

 

 

 

SELECT DISTINCT 'time'

 

 

 

then a query for each series as

 

 

 

SELECT 'result' WHERE 'unit_id' = 'A'

 

SELECT 'result' WHERE 'unit_id' = 'B' etc

 

 

 

and as long as the series queries have the same number of records as the category query and are in the same sort order its ok?

 

 

 

 

 

 

 

Thanks!

Edited by Guest

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now