Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: How do I select distinct from duplicated records and order by other column?
Look at using GROUP BY and HAVING.
Daniel Morgan
C Chang wrote:
> I have a set of records TableA as
>
> col1 col2 col3 col4
> 1 D AA D4
> 2 B BB B4
> 3 C CC C4
> 4 A DD A4
> 2 B BB B4
>
> I can not use the
> select distinct(col1), col2, col3, col4
> from tableA
> where ..
> order by col2; <-- Can be changed dynamically?
> It generates an error that " not onSelect expression" due to the col#
> that order by is not constant.
> And I can not put every columns in a group by either. So soes anyone
> have a good suggestion? Thanks.
>
> C Chang
Received on Tue Apr 23 2002 - 10:04:30 CDT