Re: [SQL] Where clause

2007-06-27 Thread Michael Landin Hostbaek
news.gmane.org (nis) writes: SELECT * FROM ( select cid,count(distinct contactid) from tracking where click = true group by cid ) c1 FULL OUTER JOIN ( select cid,count(distinct contactid) from tracking where view = true group by cid ) c2 USING (cid); That did the trick! Many thanks,

[SQL] Where clause

2007-06-26 Thread Michael Landin Hostbaek
Hello, I have a table called tracking, with a contactid varchar, click bool, view bool and cid varchar. I would like to put the following into one single query if possible: // Number of clicks select cid,count(distinct contactid) from tracking where click = true group by cid; // Number of

Re: [SQL] Where clause

2007-06-26 Thread A. Kretschmer
am Tue, dem 26.06.2007, um 10:24:05 +0200 mailte Michael Landin Hostbaek folgendes: Hello, I have a table called tracking, with a contactid varchar, click bool, view bool and cid varchar. I would like to put the following into one single query if possible: // Number of clicks select

Re: [SQL] Where clause

2007-06-26 Thread Michael Landin Hostbaek
A. Kretschmer (andreas.kretschmer) writes: *untested* select cid, sum(case when click = true then 1 else 0 end), sum(case when view = true then 1 else 0 end) from ... Thanks, but I need the DISTINCT contactid - I don't want the same contactid counted twice. Mike

Re: [SQL] Where clause

2007-06-26 Thread Achilleas Mantzios
Στις Τρίτη 26 Ιούνιος 2007 12:44, ο/η Michael Landin Hostbaek έγραψε: A. Kretschmer (andreas.kretschmer) writes: *untested* select cid, sum(case when click = true then 1 else 0 end), sum(case when view = true then 1 else 0 end) from ... Thanks, but I need the DISTINCT contactid - I

Re: [SQL] Where clause

2007-06-26 Thread Richard Huxton
Michael Landin Hostbaek wrote: A. Kretschmer (andreas.kretschmer) writes: *untested* select cid, sum(case when click = true then 1 else 0 end), sum(case when view = true then 1 else 0 end) from ... Thanks, but I need the DISTINCT contactid - I don't want the same contactid counted twice.

Re: [SQL] Where clause

2007-06-26 Thread news.gmane.org
Michael Landin Hostbaek skrev: Hello, I have a table called tracking, with a contactid varchar, click bool, view bool and cid varchar. I would like to put the following into one single query if possible: // Number of clicks select cid,count(distinct contactid) from tracking where

Re: [SQL] where clause subqueries vs multiple rows results

2006-09-11 Thread James Cloos
[SIGH] I was getting the syntax wrong. Just using ON rathar than = fixed the mistake. Time to crash for the night (day?) it seems Thanks for the replies; if I hadn't've figured it out myself they would have pushed me in the right direction. -JimC -- James Cloos [EMAIL PROTECTED]

[SQL] where clause subqueries vs multiple rows results

2006-09-10 Thread James Cloos
I've a query which I'd have liked to word akin to: SELECT guid FROM child WHERE the_fkey = ( SELECT id FROM parent WHERE name ~ 'some_regex' ) ORDER BY the_fkey, my_pkey; I got around it by doing the SELECT id first, and then doing a SELECT guid for each row returned,

Re: [SQL] where clause subqueries vs multiple rows results

2006-09-10 Thread Aaron Bono
On 9/10/06, James Cloos [EMAIL PROTECTED] wrote: I've a query which I'd have liked to word akin to:SELECT guid FROM child WHERE the_fkey = ( SELECT id FROM parent WHERE name ~ 'some_regex' ) ORDER BY the_fkey, my_pkey;I got around it by doing the SELECT id first, and then doing a SELECT guid for

Re: [SQL] where clause subqueries vs multiple rows results

2006-09-10 Thread Aaron Bono
Oops, see correction below...On 9/10/06, Aaron Bono [EMAIL PROTECTED] wrote: On 9/10/06, James Cloos [EMAIL PROTECTED] wrote: I've a query which I'd have liked to word akin to:SELECT guid FROM child WHERE the_fkey = ( SELECT id FROM parent WHERE name ~ 'some_regex' ) ORDER BY the_fkey, my_pkey;I

Re: [SQL] where clause subqueries vs multiple rows results

2006-09-10 Thread Richard Broersma Jr
I've a query which I'd have liked to word akin to: SELECT guid FROM child WHERE the_fkey = ( SELECT id FROM parent WHERE name ~ 'some_regex' ) ORDER BY the_fkey, my_pkey; I got around it by doing the SELECT id first, and then doing a SELECT guid for each row returned,