Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Mailing Lists -> Oracle-L -> Re: Comments on Why???
It's to ensure that only _one_ description gets returned per
glacct. You might assume that DISTINCT would take care of
that, but consider:
gl_acct_no=3D101, description=3DPayroll
gl_acct_no=3D101, description=3DPaychecks
Using distinct will result in two rows being returned, while your query will result in only one row being returned.
You could argue that a GL account should only have one description, but maybe your system contains some data that violates that assumption, and maybe that's why the original programmer wrote the query the way you see it.
Jonathan
On Fri, 28 Jul 2000 05:20:02 -0800, you wrote:
>Working on something someone else wrote and maybe I'm missing the =
obvious.
>But would anyone have any idea as to why someone would use the rowid in =
this
>query????
>
>insert into temp_big_gllist (glacct, desct)
>select distinct (gl_acct_no), (description)
>from gene310 t1 where t1.rowid =3D
>(select min(t2.rowid)
>from gene310 t2
>where t1.gl_acct_no =3D t2.gl_acct_no);
>
>I'm having a hard time understanding why someone would do this and of =
course
>there are no notes left behind to explain. Anyone else have any =
Received on Fri Jul 28 2000 - 09:06:44 CDT