On 06/29/11 01:01 PM, Cecil Westerhof wrote:
> 2011/6/29 Roger Andersson <r...@telia.com <mailto:r...@telia.com>>
>
>     SELECT round(cast(COUNT(rowid)*100 as real)/(SELECT COUNT(*) FROM
>     people),2) FROM people WHERE zip="12345";
>
>
> Would it not be better to do the CAST on the second SELECT? Then there 
> is only one CAST needed. In this case it does not matter much, but in 
> the general case it could.
I can only see one CAST ;-)
> Or maybe even better instead of doing * 100 in the first select, do * 
> .01 in the second.
>
:) No CAST needed
SELECT round((COUNT(rowid))/(SELECT COUNT(*)*0.01 FROM people),2) FROM 
people WHERE zip="12345";

/Roger
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to