Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: SQL Help (Art Table)

Re: SQL Help (Art Table)

From: Isaac Blank <izblank_at_yahoo.com>
Date: Mon, 24 Jan 2000 20:39:10 GMT
Message-ID: <388cb71a.90664228@news.nanospace.com>


SELECT ART_ID, ART_DATE, ART_DESC
FROM ART_TABLE T1
WHERE 3 > (SELECT COUNT(*) FROM ART_TABLE T2

	WHERE T1.ART_AD = T2.ART_ID
	AND T1.ART_DATE <= T2.ART_DATE)
ORDER BY ART_ID, 1 - (SELECT COUNT(*) FROM ART_TABLE T2
	WHERE T1.ART_AD = T2.ART_ID
	AND T1.ART_DATE <= T2.ART_DATE)


On Mon, 24 Jan 2000 18:12:15 GMT, pchapp_at_sapient.com wrote:

>Hi,
>
> I have a table art_table as follows
>
>ART_TABLE
>(ART_ID NUMBER(10),
>ART_DATE DATE,
>ART_DESC VARCHAR2(200))
>
>
>I have data in the table as follows
>
>AAA 01-20-2000 AAA Desc
>AAA 01-21-2000 AAA Desc
>AAA 01-22-2000 AAA Desc
>AAA 01-23-2000 AAA Desc
>AAA 01-24-2000 AAA Desc
>BBB 01-20-2000 BBB Desc
>BBB 01-21-2000 BBB Desc
>BBB 01-22-2000 BBB Desc
>BBB 01-23-2000 BBB Desc
>BBB 01-24-2000 BBB Desc
>
>
>I want the result set should be sorted by ART_ID and ART_DATE and show
>only the latest 3 rows. SO in our example the result set should be
>
>AAA 01-24-2000 AAA Desc
>AAA 01-23-2000 AAA Desc
>AAA 01-22-2000 AAA Desc
>BBB 01-24-2000 BBB Desc
>BBB 01-23-2000 BBB Desc
>BBB 01-22-2000 BBB Desc
>
>
>I am using Oracle 8.0.5.
>
>
>Any help will be very helpfull.
>
>Thank you very much.
>
>Prabha.
>
>
>Sent via Deja.com http://www.deja.com/
>Before you buy.
Received on Mon Jan 24 2000 - 14:39:10 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US