Yes/no pie chart

(3 posts) (2 voices)

Tags:

No tags yet.

  1. My SQL knowledge is the problem here.

    I need to chart the yes values and the no values from a field "vote" in a table. What I can't figure is how to select the 2 different aggregate totals so as to be able to use an XY chart.

    Your help is appreciated!

  2. myDBR Team, Key Master

    If your vote field contains 'yes' or 'no' you can calculate the number of occurrences with count(*):

    select 'dbr.chart', 'Pie';
    
    select vote, count(*)
    from mytable
    group by vote;

    If your vote field contains for example 1 for 'yes' and 0 for 'no', you can use if-statement to convert the values:

    select 'dbr.chart', 'Pie';
    
    select if(vote=1, 'Yes', 'No'), count(*)
    from mytable
    group by vote;

    --
    myDBR Team

  3. Thank you very much! Love your software!


Reply

You must log in to post.