Re: Optimize queries

2004-10-08 Thread SGreen
You may still be able to do this as a single query: SELECT SUM(if(field1='myvalue',1,0)) as bigTotal, SUM(if(category1 = 'myvalue',1,0)) as categoryTotal, SUM(if(category1 = 'myvalue',1.0,0))/SUM(if(field1='myvalue',1.0,0)) as CategoryPercent FROM table It performs a t

Re: Optimize queries

2004-10-08 Thread Dobromir Velev
Hi, Using sub-selects (MySQL 4.1 and higher) you can use something like select count(*)/(select count(*) from table where field1='myvalue') as percentage from table where category='myvalue' group by category; but I don't think you will gain much in performance this way. I'd rather use two queri