๐Ÿ’ SQL (Programmers)/Is Null

[ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค][SQL] ์—…๊ทธ๋ ˆ์ด๋“œ ํ•  ์ˆ˜ ์—†๋Š” ์•„์ดํ…œ ๊ตฌํ•˜๊ธฐ (level3)

์„ ๋‹ฌ 2024. 10. 30. 16:47
๋ฐ˜์‘ํ˜•

๋ฌธ์ œ

๋” ์ด์ƒ ์—…๊ทธ๋ ˆ์ด๋“œํ•  ์ˆ˜ ์—†๋Š” ์•„์ดํ…œ์˜ ์•„์ดํ…œ ID(ITEM_ID), ์•„์ดํ…œ ๋ช…(ITEM_NAME), ์•„์ดํ…œ์˜ ํฌ๊ท€๋„(RARITY)๋ฅผ ์ถœ๋ ฅํ•˜๋Š” SQL ๋ฌธ์„ ์ž‘์„ฑํ•ด ์ฃผ์„ธ์š”.

์ด๋•Œ ๊ฒฐ๊ณผ๋Š” ์•„์ดํ…œ ID๋ฅผ ๊ธฐ์ค€์œผ๋กœ ๋‚ด๋ฆผ์ฐจ์ˆœ ์ •๋ ฌํ•ด ์ฃผ์„ธ์š”.

 

ํ’€์ด

select ITEM_ID, ITEM_NAME, RARITY
from ITEM_INFO
where ITEM_ID in 
    (
        select p.ITEM_ID as no_more_upgrade
        from ITEM_TREE p left join ITEM_TREE c on p.ITEM_ID = c.PARENT_ITEM_ID
        where c.ITEM_ID is null 
    )
order by ITEM_ID desc

 

๋ฐ˜์‘ํ˜•