Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: How can we make distinct of one particular column!
But is this what you asked for Pedro?
Joel's query does not appear to select all the rows from table.I thought all you asked for was simply to display column 2 once for each distinct value i.e.
COL1 COL2 COL3 AAAA 1111 XXXX BBBB YYYY CCCC ZZZZ DDDD 2222 ++++
i.e. "eliminating the repetitions of column2."
See my solution in my earlier e-mail
Lawrence Simela
MAHALINI CONSULTING LIMITED
> Well that's one solution by Joel R. Kallman:
>
>What you are saying is that you want to select only one row from this
>table for each unique value of "column2". I am assuming that you do
>not care which row gets selected.
>
>By issuing the query:
>
> SELECT MIN(rowid) FROM table GROUP BY column2
>
>you are identifying only one row from table for each unique value of
>column2.
>
>Now, by turning this into a subselect, you ultimately get the query
>that you want:
>
> SELECT column1, column2, column3 FROM table
> WHERE rowid IN
> (SELECT MIN(rowid) FROM table GROUP BY column2)
>
>This will work for everything but index-organized tables in Oracle8
>(which do not have rowid's).
>
>Thanks!
>
>Joel
>
>Joel R. Kallman Enabling the Information Age!
>Oracle Government, Education, & Health
>Columbus, OH http://govt.us.oracle.com
>jkallman@us.oracle.com http://www.oracle.com
>
>----
>The statements and opinions expressed here are my own
>and do not necessarily represent those of Oracle Corporation.
>
Received on Wed Jan 07 1998 - 00:00:00 CST
![]() |
![]() |