"Harald Fuchs" <[EMAIL PROTECTED]> writes:
> If you want to select both columns, but have uniqueness over the first
> only, you can use a derived table:
>
> SELECT tbl.name, tbl.comment
> FROM tbl
> JOIN (SELECT name FROM tbl GROUP BY name HAVING count(*) = 1) AS t
> ON t.name = tbl.name
>
Or u
In article <[EMAIL PROTECTED]>,
Phil Rhoades <[EMAIL PROTECTED]> writes:
> People,
>> select count(*) as cnt, name from tst group by name having count(*) = 1
> This worked for my basic example but not for my actual problem - I get
> "column comment must appear in the GROUP BY clause or be used i
Mike,
I can't do that with my comments - I get all six of the records in the
result with the example instead of just four like I want . . but someone
else had a solution without using the "group by" clause . .
Phil.
On Sun, 2008-01-27 at 13:56 -0500, Mike Ginsburg wrote:
> Hi Phil,
> Each of
johnf <[EMAIL PROTECTED]> writes:
> On Sunday 27 January 2008 10:56:18 am Mike Ginsburg wrote:
>> Each of columns that you specify in your SELECT clause, must also
>> appear in the GROPU BY clause.
> Is the requirement of select fields matching group by fields a SQL92
> requirement or something t
On Sunday 27 January 2008 10:56:18 am Mike Ginsburg wrote:
> Hi Phil,
> Each of columns that you specify in your SELECT clause, must also
> appear in the GROPU BY clause.
>
> SELECT COUNT(*) AS cnt, name, comment, ...
> FROM tst
> GROUP BY name, comment, ...
> HAVING COUNT(*) = 1;
>
Is the requir
Hi Phil,
Each of columns that you specify in your SELECT clause, must also
appear in the GROPU BY clause.
SELECT COUNT(*) AS cnt, name, comment, ...
FROM tst
GROUP BY name, comment, ...
HAVING COUNT(*) = 1;
Phil Rhoades wrote:
People,
select count(*) as cnt, name from tst group by nam
People,
> select count(*) as cnt, name from tst group by name having count(*) = 1
This worked for my basic example but not for my actual problem - I get
"column comment must appear in the GROUP BY clause or be used in an
aggregate function" errors so I have a related question:
With table:
nam
Guys,
On Sun, 2008-01-27 at 17:38 +0100, Pavel Stehule wrote:
> On 27/01/2008, Phil Rhoades <[EMAIL PROTECTED]> wrote:
> > Tino,
> >
> >
> > On Sun, 2008-01-27 at 15:16 +0100, Tino Wildenhain wrote:
> > > Phil Rhoades wrote:
> > > > People,
> > > >
> > > > I want to select from a table ONLY uniqu
On 27/01/2008, Phil Rhoades <[EMAIL PROTECTED]> wrote:
> Tino,
>
>
> On Sun, 2008-01-27 at 15:16 +0100, Tino Wildenhain wrote:
> > Phil Rhoades wrote:
> > > People,
> > >
> > > I want to select from a table ONLY unique records ie if a column has
> > > values:
> > >
> > > 1
> > > 2
> > > 3
> > > 3
>
On Mon, Jan 28, 2008 at 03:32:18AM +1100, Phil Rhoades wrote:
> SELECT count(*) as cnt, name FRoM tst GROUP BY name HAVING cnt = 1 ;
> ERROR: column "cnt" does not exist
> LINE 1: ...ount(*) as cnt, name FRoM tst GROUP BY name HAVING cnt = 1 ;
having count(*) = 1;
depesz
--
quicksil1er: "postg
Tino,
On Sun, 2008-01-27 at 15:16 +0100, Tino Wildenhain wrote:
> Phil Rhoades wrote:
> > People,
> >
> > I want to select from a table ONLY unique records ie if a column has
> > values:
> >
> > 1
> > 2
> > 3
> > 3
> > 4
> > 5
> >
> > I want ONLY these records returned:
> >
> > 1
> > 2
> > 4
Pavel,
You didn't read my note properly - your query gives:
1
2
3
4
5
I want:
1
2
4
5
Phil.
On Sun, 2008-01-27 at 15:10 +0100, Pavel Stehule wrote:
> Hello
>
> try
>
> SELECT DISTINCT col FROM table
>
> Pavel
>
> On 27/01/2008, Phil Rhoades <[EMAIL PROTECTED]> wrote:
> > People,
> >
> >
Phil Rhoades wrote:
People,
I want to select from a table ONLY unique records ie if a column has
values:
1
2
3
3
4
5
I want ONLY these records returned:
1
2
4
5
SELECT count(*) as cnt,a,b,c FORM yourtable
GROUP BY a,b,c
HAVING cnt=1
should do.
Regards
Tino
---(en
Hello
try
SELECT DISTINCT col FROM table
Pavel
On 27/01/2008, Phil Rhoades <[EMAIL PROTECTED]> wrote:
> People,
>
> I want to select from a table ONLY unique records ie if a column has
> values:
>
> 1
> 2
> 3
> 3
> 4
> 5
>
> I want ONLY these records returned:
>
> 1
> 2
> 4
> 5
>
> Thanks,
>
>
People,
I want to select from a table ONLY unique records ie if a column has
values:
1
2
3
3
4
5
I want ONLY these records returned:
1
2
4
5
Thanks,
Phil.
--
Philip Rhoades
Pricom Pty Limited (ACN 003 252 275 ABN 91 003 252 275)
GPO Box 3411
Sydney NSW 2001
Australia
Fax: +61:(0)
15 matches
Mail list logo