Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Union Query Improvement
On Feb 14, 9:59 am, "Ray Bannon" <raymond.w.ban..._at_boeing.com> wrote:
> Howdy, I've got a query which runs forever and am wondering if there's a
> more efficient way to write it.
>
> Select id, plan_name from table/view1 where plan_name = 'A' and rownum = 1
> union
> Select id, plan_name from table/view1 where plan_name = 'B' and rownum = 1
> union
> Select id, plan_name from table/view1 where plan_name = 'C' and rownum = 1
> union.....etc
>
> There are about 100 plan names, and I want one ID/owner for each plan_name.
wouldn't
SELECT DISTINCT id, plan_name from table/view1 ;
work?
I dislike DISTINCT since many folks use it for the wrong reasons, but
this seems a perfect place for it.
Ed Received on Wed Feb 14 2007 - 09:39:25 CST