Re: Interesting SQL Query - Total and Grouped Counts together?

2007-04-30 Thread Imran Chaudhry
Baron, Thanks very much for that simple but very effective solution. I altered your SQL slightly, the final SQL looks like this: SELECT domain, count(*) AS 'count all', SUM(IF(mime = 'text/html', 1, 0)) AS 'count text', SUM(IF(mime LIKE 'image/%', 1, 0)) AS 'count image' FROM tableA

Interesting SQL Query - Total and Grouped Counts together?

2007-04-26 Thread Imran Chaudhry
I'm wondering if any of you can assist with an interesing SQL query. I have a single table within a database, the relevant fields of which are defined as: CREATE TABLE tableA ( domain text, mime text ); Where domain is a domain, such as:

Re: Interesting SQL Query - Total and Grouped Counts together?

2007-04-26 Thread Baron Schwartz
Hi, Imran Chaudhry wrote: I'm wondering if any of you can assist with an interesing SQL query. I have a single table within a database, the relevant fields of which are defined as: CREATE TABLE tableA ( domain text, mime text ); Where

Re: Interesting SQL Query - Total and Grouped Counts together?

2007-04-26 Thread Mogens Melander
On Thu, April 26, 2007 18:38, Baron Schwartz wrote: Hi, Imran Chaudhry wrote: I'm wondering if any of you can assist with an interesing SQL query. I have a single table within a database, the relevant fields of Try IF or CASE expressions: SELECT foo, count(*), sum(case when foo = 'bar'