Re: query using distinct and count
From: mgm (martorellg_at_hotmail.com)
Date: 11/02/04
- Next message: Steve Kass: "Re: query using distinct and count"
- Previous message: Dan Guzman: "Re: HowTo: Append data to a table stored in another database?"
- In reply to: Steve Kass: "Re: query using distinct and count"
- Next in thread: Steve Kass: "Re: query using distinct and count"
- Reply: Steve Kass: "Re: query using distinct and count"
- Messages sorted by: [ date ] [ thread ]
Date: Mon, 1 Nov 2004 21:41:28 -0800
Thank you for the response!
But I'm still kinda stuck on this...
If i'm only selecting 1 column of distinct (non-duplicate) values
it still seems that it should return the same as if I select all of
those values that occur only once in that column.
I don't know why i'm not seeing it.
"Steve Kass" <skass@drew.edu> wrote in message
news:OzizuAIwEHA.2568@TK2MSFTNGP11.phx.gbl...
>
>
> mgm wrote:
>
> >if you query for * and get a rowcount of 50 (no nulls) then query for a
> >distinct
> >column and get a rowcount of 30 I would assume 20 have repetitions.
> >
> > select distinct column from table
> >
> >
> This returns one copy of every value in column, whether that value
> appears once, twice, or more often in the table.
> It's not "select the values that are unique" from table. It's "select
> each different value appearing" in the table.
>
> DISTINCT does not apply to [column]. DISTINCT applies to SELECT. Maybe
> it would be easier to figure out if it were
>
> SELECT EACH JUST ONCE
> column,
> othercolumn
> FROM T
>
> >if you query for the same column and group by that column having a count
(*)
> >= 1
> >shouldn't that work the same way?
> >
> > select column from table
> > group by column
> > having count(*) = 1
> >
> >
> This does not return those values appearing more than once in the table,
> so it will return fewer rows. To get the same number of rows as before,
> remove the HAVING clause.
>
> Steve Kass
> Drew University
>
> >My rowcounts don't equal, I know I'm missing something obvious,
> >can someone please explain what it is?
> >
> >Thanks!
> >mgm
> >
> >
> >
> >
- Next message: Steve Kass: "Re: query using distinct and count"
- Previous message: Dan Guzman: "Re: HowTo: Append data to a table stored in another database?"
- In reply to: Steve Kass: "Re: query using distinct and count"
- Next in thread: Steve Kass: "Re: query using distinct and count"
- Reply: Steve Kass: "Re: query using distinct and count"
- Messages sorted by: [ date ] [ thread ]