SayYou_SayMe
asked on
Oracle join
I have table A with sys_ID,business_ID,update_ date columns
1 102 11/20/1990
2 102 11/21/2009
it will be join table B business_ID,....C
I only want to get the max(update_date) row to join to B..C
can I do like this?
select * from B,C,(select * from A group by buisiness_ID having update_date=max(update_dat e) A
where D.business_ID=B.business_I D
and B.ID=C.ID
Is there any way to do this? because if I join many tables and A has many columns
, it is painful
1 102 11/20/1990
2 102 11/21/2009
it will be join table B business_ID,....C
I only want to get the max(update_date) row to join to B..C
can I do like this?
select * from B,C,(select * from A group by buisiness_ID having update_date=max(update_dat
where D.business_ID=B.business_I
and B.ID=C.ID
Is there any way to do this? because if I join many tables and A has many columns
, it is painful
ASKER
select sys_id, business_id, max(update_date) from tableA
have to "group by sys_id, business_id"
have to "group by sys_id, business_id"
ASKER
CAN these 2 query get the same result?
SELECT A.BUSINESS_ID,A.UPDATE_DAT E FROM
( select A.BUSINESS_ID,A.UPDATE_DAT E from A,B,C
where A.BUSINESS_ID=B.BUSINESS_I D
and B.ID=C.ID) D
GROUP BY D.BUSINESS_ID
HAVING UPDATE_DATE=MAX(UPDATE_DAT E)
select A.BUSINESS_ID,A.UPDATE_DAT E from B,C,(select A.BUSINESS_ID,A.UPDATE_DAT E from A group by buisiness_ID having update_date=max(update_dat e) A
where D.business_ID=B.business_I D
and B.ID=C.ID
SELECT A.BUSINESS_ID,A.UPDATE_DAT
( select A.BUSINESS_ID,A.UPDATE_DAT
where A.BUSINESS_ID=B.BUSINESS_I
and B.ID=C.ID) D
GROUP BY D.BUSINESS_ID
HAVING UPDATE_DATE=MAX(UPDATE_DAT
select A.BUSINESS_ID,A.UPDATE_DAT
where D.business_ID=B.business_I
and B.ID=C.ID
check this.
SELECT *
FROM A t1,B t2,C t3
WHERE t1.business_ID = t2.business_ID
AND t2.ID = t3.ID
AND t1.update_date = (SELECT t4.update_date
FROM A t4
WHERE t1.business_ID = t2.business_ID)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
(select sys_id, business_id, max(update_date) from tableA) a,
tableB b
where tableA.business_id=tableB.
and tableA.sys_id=tableB.sys_i
I am assuming you want max of the update_date by grouping the other 2 columns!