kurky17 Posted June 23, 2010 Share Posted June 23, 2010 Hi all,I have a table like the one below:tablename: daily_totals packageID total_bytes date 0123 10 2009-01-01 0123 20 2009-01-02 0124 10 2009-01-01 0124 20 2009-01-02 0125 10 2009-01-01 0125 20 2009-01-02 I need to create a chart based on what package ID the user wants to show with the date as the Xaxis and the total_bytes as the Y-axis. He can choose one, or many packages. He also has the option to choose ALL. Which means, my chart legend can be the one below if he chooses to show everything: Package 0123 Package 0124 Package 0125 All*The ALL option is simply summing up the total_bytes of all packageIDs in a given date.My sql query for per package will be something like:SELECT packageID, total_bytes, date FROM daily_totalsWHERE packageID = 0123Result: packageID total_bytes date 0123 10 2009-01-01 0123 20 2009-01-02 My sql query for All Packages will be something like:SELECT sum(total_bytes), date FROM daily_totalsGROUP BY dateResult: total_bytes date 30 2009-01-01 60 2009-01-02 No, I can't do a UNION because i don't think i can do away with the packageID field for the first query. How can I show these data on a chart? My chart legend should have packageID 123 and ALL.Please help me. Thanks,Michelle Link to comment Share on other sites More sharing options...
pwd Posted June 25, 2010 Share Posted June 25, 2010 if you change your 2nd query to somthing like: SELECT '' as packageID,sum(total_bytes), date FROM daily_totalsGROUP BY date you'll be able to do a union Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now