Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.tools -> Re: Help with SQL query
Hello Graham,
created the two tables, inserted just a few test rows to show the principle:
create table faq_m(
faq_id number(8) constraint pk_faq_id primary key ); create table faq_d( faq_id number(8) constraint fk_faq_id references faq_m(faq_id), fname varchar2(10), lname varchar2(10), entry_date date)
select m.faq_id, max(d.fname), count(d.fname), d.lname, d.entry_date
from faq_m m, faq_d d
where m.faq_id = d.faq_id
and d.entry_date < sysdate - 8
group by m.faq_id, d.lname, d.entry_date;
FAQ_ID MAX(D.FNAM COUNT(D.FNAME) LNAME ENTRY_DAT
---------- ---------- -------------- ---------- --------- 1 surname1 2 lname1 25-JUL-01 2 surname2 1 lname2 20-JUL-01 2 surname2 1 lname2 25-JUL-01 3 surname3 1 lname3 10-JUL-01
hope that helps
Manuela Mueller
Received on Fri Aug 03 2001 - 15:47:06 CDT