>I'm trying to pull percentages from a query and
>really don't understand how to initiate this.
SELECT COUNT(*) INTO @total FROM venues;
SELECT venueID, COUNT(venueID)*100/@total AS Pct FROM venues GROUP BY
venueID;
PB
Paul Nowosielski wrote:
> Dear All,
>
> I'm trying to pull percentages from a query and really don't understand how to
> initiate this.
>
> Here is the low down:
>
> I have a list of venues with the number of acts who performed catoragized by
> genre.
>
> For example:
>
> venue_id: 23 blues: 117 rock: 34 world_music:57 ( and so on, there are 24
> genres listed.)
>
> So my question would be how can I write a query to spit out a result set like:
> venue_id:24 blues:34(%) rock:12(%) world music:3(%) comedy: 0(%)
>
> Is this possible?
>
> here is the table structure:
> venue_id int(6) PRI 0
> Actor int(6) 0
> Adult Contemporary int(6) 0
> Alternative int(6) 0
> Blues int(6) 0
> Children's Entertainment int(6) 0
> Christian int(6) 0
> Classic Rock int(6) 0
> Classical int(6) 0
> Comedy int(6) 0
> Country int(6) 0
> Dance int(6) 0
> Folk int(6) 0
> Holiday int(6) 0
> Jazz int(6) 0
> Latin int(6) 0
> Lecturers & Speakers int(6) 0
> Magician int(6) 0
> Reggae int(6) 0
> Rock int(6) 0
> Sports/Athletics int(6) 0
> Urban int(6) 0
> Variety int(6) 0
> World Music int(6) 0
>
> Any help would really be appreciated!
>
> Best,
>
>
--
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.409 / Virus Database: 268.14.2/528 - Release Date: 11/10/2006