D_NO VARCHAR2(20)
D_DATE DATE
BUDGET_HEAD VARCHAR2(50)
CONC_PO VARCHAR2(50)
AMOUNT NUMBER
REMARKS VARCHAR2(400)
DIV VARCHAR2(30)
DESCRIPTION VARCHAR2(2000)
SUB_HEAD VARCHAR2(50)
F_DEM_PROG
D_NO VARCHAR2(20)
REC_FROM VARCHAR2(500)
SENT_TO VARCHAR2(500)
TD_DATE DATE
ACTION VARCHAR2(500)
REMARKS VARCHAR2(2000)
SNO NUMBER
I need to have the last three records from each d_no . What would
be the query which will return last three records from each d_no
depending whatever div is selected by the user.
Hi Folks, I have the following master-detail tables: CASESD_NO VARCHAR2(20)D_DATE DATEBUDGET_HEAD VARCHAR2(50)CONC_PO VARCHAR2(50)AMOUNT NUMBERREMARKS VARCHAR2(400)DIV VARCHAR2(30)DESCRIPTION VARCHAR2(2000)SUB_HEAD VARCHAR2(50) F_DEM_PROGD_NO VARCHAR2(20)REC_FROM VARCHAR2(500)SENT_TO VARCHAR2(500)TD_DATE DATEACTION VARCHAR2(500)REMARKS VARCHAR2(2000)SNO NUMBER I need to have the last three records from each d_no . What wouldbe the query which will return last three records from each d_nodepending whatever div is selected by the user. Hassan
I need to have the last three records from each d_no . What would be the query which will return last three records from each d_no depending whatever div is selected by the user. Hassan
Define "last three." Heap tables don't have an order.
Show us your current best attempt and we will give you a hint.
--
Daniel Morgan
University of Washington
Puget Sound Oracle Users Group
I need to have the last three records from each d_no . What would be the query which will return last three records from each d_no depending whatever div is selected by the user. Hassan
Define "last three." Heap tables don't have an order. Show us your current best attempt and we will give you a hint. -- Daniel Morgan University of Washington Puget Sound Oracle Users Group
Hi,
Each record in the ind_prog table is saved with a sequence number in
the SNO field, therefore the last three records for each d_no will be
its last three maximun sequence number. I used the following query
which works fine for a single d_no on the f_dem_prog table:
select d_no,rec_from,sent_to,td_date,sno
from(select d_no,rec_from,sent_to,td_date,sno
from f_dem_prog where d_no='&d_no'
order by sno desc) where rownum<4
The MyLounge.com forum is intended for informational use only and should not
be relied upon and is not a substitute for any advice. The information contained
on MyLounge.com are opinions and suggestions of members and is not a representation
of the opinions of MyLounge.com. MyLounge.com does not warrant or vouch for
the accuracy, completeness or usefulness of any postings or the qualifications
of any person responding. Please consult a expert or seek the services of an
attorney in your area for more accuracy on your specific situation. Please note
that our forums also serve as mirrors to Usenet newsgroups. Many posts you see
on our forums are made by newsgroup users who may not be members of MyLounge.com
Term of Service