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
Hello Dobromir,
Friday, October 8, 2004, 3:47:06 PM, you wrote:
DV> Hi,
DV> Using sub-selects (MySQL 4.1 and higher) you can use something like
DV> select count(*)/(select count(*) from table where field1='myvalue') as
DV> percentage from table where category='myvalue' group by category;
DV>
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
Hello there,
Until I had query time restriction due to my web hoster. Meaning
whenever the query was too long, it gets killed !
Now I have changed my webhoster, I'd like to optimize my queries and I
would like to have your opinion on that.
I wrote multiple queries to prevent any long query