Write a query to retrieve the latest records from the table sorted by version(scd).

Questions by ravi214u   answers by ravi214u

Showing Answers 1 - 15 of 15 Answers

sunil

  • Feb 27th, 2007
 

you can write a query like inline view clause you can compare previous version to new highest version then you can get your result 

  Was this answer useful?  Yes

Hanu Ch Rao

  • Mar 1st, 2007
 

Hi,

Assume if you put the surrogate key in target (Dept table) like p_key and
version field, dno field and loc field is there
then


select a.p_key, a.dno, a.loc, a.version from t_dept a
where a.version = (select max(b.version) from t_dept  b where a.dno=b.dno)

this is the query if you write in lookup it retrieves latest (max)
version in lookup from target. in this way performance increases.
 

  Was this answer useful?  Yes

ketannp

  • Feb 9th, 2008
 

Select Acct.*,Rank() Over ( partition by ch_key_id order by version desc) as Rank
from Acct
where Rank()=1

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions