Home » SQL & PL/SQL » SQL & PL/SQL » problem in a query
problem in a query [message #7665] Sat, 28 June 2003 07:10 Go to next message
lajna
Messages: 8
Registered: June 2003
Junior Member
hi

i have a query as below
select account_no,business_date,max(journal_no) from
(select max(sequence_number), account_no,business_date,journal_no from cs_deposit_txns_hist
where account_no =151022322
group by business_date, account_no,journal_no)
group by business_date,account_no;

In the output i need to have the sequence no also of the row that i retrieve from cs_deposit_txns_hist.

Urgent help required.

Thanks
Lajna
Re: problem in a query [message #7672 is a reply to message #7665] Sun, 29 June 2003 23:52 Go to previous messageGo to next message
Maaher
Messages: 7065
Registered: December 2001
Senior Member
Try the following :
SELECT <B>seq_no</B>
     , account_no,business_date
     , max(journal_no) journal_no
  FROM ( SELECT max(sequence_number) <B>seq_no</B>
              , account_no
              , business_date
              , journal_no 
           FROM cs_deposit_txns_hist 
          WHERE account_no = 151022322 
          GROUP BY business_date
              , account_no
              , journal_no
       )
 GROUP BY <B>seq_no</b>
        , business_date
        , account_no;
HTH,
MHE
Re: problem in a query [message #7856 is a reply to message #7672] Sun, 13 July 2003 07:52 Go to previous message
lajna
Messages: 8
Registered: June 2003
Junior Member
thanks for the reply.

It worked this way :=
Select Memb_Cust_Ac, Business_Date,Jrnl_No, max(Sequence_Number)
From Cs_Bgl_Txns_Hist
Where (Memb_Cust_Ac,Business_Date,Jrnl_No) in
(Select Memb_Cust_Ac,business_date,max(jrnl_no)
From CS_Bgl_Txns_Hist
Group by business_date, Memb_Cust_Ac )
Group by business_date, Memb_Cust_Ac,jrnl_no
Previous Topic: PL/SQL Gateway
Next Topic: index query
Goto Forum:
  


Current Time: Thu Apr 25 15:08:09 CDT 2024