17,086
社区成员
发帖
与我相关
我的任务
分享
SELECT m.ID,
m.NAME,
DECODE(m.cnt, 1, m.age, 0) age,
m.birthplace
FROM (SELECT t.*,
row_number() OVER(PARTITION BY t.NAME, t.birthplace ORDER BY t.ID) cnt
FROM table_test t) m
ORDER BY 1
select id,name, case when name||birthplace=lab then 0 else age end age,birthplace from (
SELECT t.*,
lag(t.name || t.birthplace) over(PARTITION BY t.name, t.birthplace ORDER BY id) lab
FROM table_test t);