November 6, 2004 at 8:05 am
hey all
i got a pblm.i am unable 2 explain that. so i will give an example.
Table:
name mark
abc 10
cde 20
def 30
gfh 40
xyz 30
www 20
now the output i require is:// first occurance of mark=20.(i presume this could be done using Top key word?)
name mark
cde 20
then 2nd output i require is//last occurance of mark=20
name mark
www 20
Thanx
Rajiv.
November 7, 2004 at 4:23 pm
If 'first' = 'min' and 'last' = 'max', then this will do it:
select min(name) as 'first', max(name) as 'last'
from
where mark = 20
Regards
Phil
The absence of evidence is not evidence of absence
- Martin Rees
The absence of consumable DDL, sample data and desired results is, however, evidence of the absence of my response
- Phil Parkin
November 8, 2004 at 5:23 am
Try this examples
select
*
from
employees
where
employeeid = (select min(Employeeid) from employees) or
employeeid = (select max(Employeeid) from employees)
or
select
*
from
employees
where
employeeid in
((select min(Employeeid) from employees),
(select max(Employeeid) from employees))
November 9, 2004 at 12:19 pm
I have to ask the question - why do you care which row contains the first occurance of a value?
in a relational database the order of rows in a table is supposed to be irrelevant. You must use ORDER BY to retrieve rows in any meaningful order.
-Ken
November 11, 2004 at 11:35 am
hey all
thanx for all ur help. answering to ken's question-->i wanna know how to select a row based on rownumber.
is there any equivalent to rownum and rowid in oracle
thanx
Rajiv.
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply