Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: need help with this query
Hello Dominick,
try this:
select ssno, agency, min(begin_date)
from timedb
where payno ='817'
group by ssno, agency
In this case you don't need the distinct (the group by will result in one row for each ssno/agency combination), and you don't need the 'order by' because the 'group by' will also sort your results.
Hope this helps
Jac. Beekers
Dominick Logiudice wrote in message
<3654547F.5BEC79E1_at_pine.vpcc.sunysb.edu>...
>I have db with timesheets db looks like this
>SSNO,AGENCY,ACCTNO,PAYNO,TIME_PAYNO,BEGINDATE,ENDDATE
>The person could have multiple timesheets and
>agency can be 1 or 3.
>We want the distinct ssn ,agency,min(begin_date)
>where the payno = '817'
>So if a person was there like this:
>ssn agency begindate payno
>111111111 1 09/01/98 817
>111111111 1 09/10/98 817
>111111111 3 09/02/98 817
>111111111 3 09/15/98 817
>
>I looking for this as my answer
>ssn agency begindate payno
>111111111 1 09/01/98 817
>111111111 3 09/02/98 817
>
>Using this query
>select distinct ssno,ageny from timedb
>where payno = '817'
>order by ssno,payno
>I get these results, but when I can't get the min(begindate)
>ssn agency
>111111111 1
>111111111 3
>
>Any Idea's
Received on Thu Nov 19 1998 - 14:43:30 CST
![]() |
![]() |