Re: how/what should be the query for this result
- From: "Peter" <someone@xxxxxxxxxxxxx>
- Date: Tue, 4 Jul 2006 01:31:51 +0200
Hari,
You are so funny.
Cloud, this could be the answer you are looking for:
select
p1.P_no,
p1.b_no,
p1.status,
p1.build_date
from
Progress p1
where
build_date = (
select
max(build_date)
from
Progress p2
where
p2.P_no = p1.P_no and
p2.b_no = p1.b_no)
Or it can be:
select
p1.P_no,
p1.b_no,
p1.status,
p1.build_date
from
Progress p1
where
build_date = (
select
max(build_date)
from
Progress p2
where
p2.b_no = p1.b_no)
Or it can be
select
p1.P_no,
p1.b_no,
p1.status,
p1.build_date
from
Progress p1
inner join (
select
P_no P_no,
b_no b_no,
max(build_date) build_date
from
Progress
group by
P_no,
b_no) p2 on
p2.P_no = p1.P_no and
p2.b_no = p1.b_no and
p2.build_date = p1.build_date
Or it can be
select
p1.P_no,
p1.b_no,
p1.status,
p1.build_date
from
Progress p1
inner join (
select
b_no b_no,
max(build_date) build_date
from
Progress
group by
b_no) p2 on
p2.b_no = p1.b_no and
p2.build_date = p1.build_date
"Hari" <hkvats_1999@xxxxxxxxx> wrote in message
news:1151509079.446956.36560@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Query for getting o/p specified by you could be...I have 1 table "Progress"
SELECT P_No, B_No, Max(Status) Status, Max(Build_Date)
FROM Progess
GROUP BY P_No, B_No
==============================================
Pls note this query is executed against the sample data specified by
you.
-Hari Sharma
NIIT Technologies, India
P_no b_no status build_date
----------------------------------------------------------------
25 1 First_slab 2006/4/5
25 1 second slab 2006/5/6
25 2 first slab 2006/1/2
25 2 third slab 2006/2/3
o/p should be as
Pno,bno, status, max(build_date)
sample o/p can be as below
25 1 second slab 2006/5/6
25 2 third slab 2006/2/3
.
- Follow-Ups:
- Re: how/what should be the query for this result
- From: KLDBA
- Re: how/what should be the query for this result
- Prev by Date: Re: sql express vs msde 2000 = reverting back to msde 2000
- Next by Date: Re: IF within CASE
- Previous by thread: Re: sql express vs msde 2000 = reverting back to msde 2000
- Next by thread: Re: how/what should be the query for this result
- Index(es):
Relevant Pages
|