Re: ROWNUM for different values of a Field

From: Jining Han <hanj_at_mailcity.com>
Date: 10 Sep 2001 17:20:51 -0700
Message-ID: <1ba3bb20.0109101620.546a69c9_at_posting.google.com>


You can use UNION.

JH

Hareesh.Gunti_at_rapistan.com (Hareesh) wrote in message news:<48b2e14.0109100921.3013fecb_at_posting.google.com>...
> Hi,
>
> I have a table say Table1
> with Field1, Field2, FieldDate
> Field1, Field2 is the Primary Key
>
> SELECT * FROM (SELECT * FROM Table1 ORDER BY FieldDate)
> WHERE Field1 = 1 AND ROWNUM < 2;
>
> Gives one Record for Field1 = 1
> Similarly for Field1 = 2 and Field1 = 3
>
> SELECT * FROM (SELECT * FROM Table1 ORDER BY FieldDate)
> WHERE Field1 = 2 AND ROWNUM < 2;
> SELECT * FROM (SELECT * FROM Table1 ORDER BY FieldDate)
> WHERE Field1 = 3 AND ROWNUM < 2;
>
> Instead of writing multiple SELECT stmts or using a For Loop
> How can I accomplish this in a single SELECT
> stmt so that I get 1 record for each value
> of Field1
>
> Thanks in advance
> Hareesh
Received on Tue Sep 11 2001 - 02:20:51 CEST

Original text of this message