Jump to content

Oracle Guru's Ki Oka Question


Kakateyudu

Recommended Posts

na table ela vundhi

 

ID_NUM, Created_Date

1                3-10-2016  

2                2-10-2008

1                3-10-2012   

2                2-10-2014

1                3-10-2011   

2                2-10-2010

1                3-10-2009   

2                2-10-2016

 

aa table meda oka view create cheyyali.... It should return only 1 row per ID_NUM and that row should be the one with latest created_date.

 

aa paina example ki output below la vundali

 

ID_NUM, Created_Date

1                3-10-2016   

2                2-10-2016

 

CITI#H@  CITI#H@

 

 

 

 

Link to comment
Share on other sites

  • Replies 39
  • Created
  • Last Reply

Top Posters In This Topic

  • Kakateyudu

    9

  • loveindia

    8

  • vikuba

    6

  • mettastar

    5

SELECT ID_NUM, CREATED_DATE FROM 

(

select 

ID_NUM,

CREATED_DATE,

MAX(CREATED_DATE) OVER(PARTITION BY ID_NUM) LATEST_DATE

FROM TABLE

) A

WHERE CREATED_DATE=LATEST_DATE

Link to comment
Share on other sites

SELECT ID_NUM, CREATED_DATE FROM 

(

select 

ID_NUM,

CREATED_DATE,

MAX(CREATED_DATE) OVER(PARTITION BY ID_NUM) LATEST_DATE

FROM TABLE

) A

WHERE CREATED_DATE=LATEST_DATE

 

max vadi group by cheyaledu, wrong answer

Link to comment
Share on other sites

max vadi group by cheyaledu, wrong answer

lol.. adi analytical function antaru vuncle.. no group needed.. im partitioning in the function 

Link to comment
Share on other sites

SELECT ID_NUM, CREATED_DATE FROM
(
select
ID_NUM,
CREATED_DATE,
MAX(CREATED_DATE) OVER(PARTITION BY ID_NUM) LATEST_DATE
FROM TABLE
) A
WHERE CREATED_DATE=LATEST_DATE


Oka ID_Num ki same created_date vunte oka row kavali baa.. This returns all those rows
Link to comment
Share on other sites

Oka ID_Num ki same created_date vunte oka row kavali baa.. This returns all those rows

 

idi try cheyi

select
ID_NUM,
CREATED_DATE

FROM

(

SELECT ID_NUM, CREATED_DATE, row_number() OVER(PARTITION BY ID_NUM ORDER BY CREATED_DATE DESC) AS RNK
FROM TABLE
)
WHERE RNK = 1;

 

 

Inko approach dorikindi search cheste, idi test kudirite cheppu

 

select * id_num, latest_date from

(
select
ID_NUM,
CREATED_DATE,
MAX(CREATED_DATE) KEEP (DENSE_RANK LAST ORDER BY CREATED_DATE)

 OVER(PARTITION BY ID_NUM) LATEST_DATE
FROM TABLE
)

 

Link to comment
Share on other sites

idi try cheyi

select
ID_NUM,
CREATED_DATE

FROM

(

SELECT ID_NUM, CREATED_DATE, DENSE_RANK() OVER(PARTITION BY ID_NUM ORDER BY CREATED_DATE DESC) AS RNK
FROM TABLE
)
WHERE RNK = 1

deeniki kuda rendu records vastayi... 

Link to comment
Share on other sites

idi try cheyi
select
ID_NUM,
CREATED_DATE
FROM
(
SELECT ID_NUM, CREATED_DATE, row_number() OVER(PARTITION BY ID_NUM ORDER BY CREATED_DATE DESC) AS RNK
FROM TABLE
)
WHERE RNK = 1;


Inko approach dorikindi search cheste, idi test kudirite cheppu

select * id_num, latest_date from
(
select
ID_NUM,
CREATED_DATE,
MAX(CREATED_DATE) KEEP (DENSE_RANK LAST ORDER BY CREATED_DATE)
OVER(PARTITION BY ID_NUM) LATEST_DATE
FROM TABLE
)


Top one working baa... Tnx u da man

Will try below one too
Link to comment
Share on other sites

×
×
  • Create New...