SQL 기초 실무/빅데이터 문제 풀기
23.10.04. SQL Developer 빅데이터 분석하기 ③
잇꼬
2023. 10. 4. 09:27
728x90
반응형
SMALL
3. 스티븐 잡스 연설문에서의 긍정단어와 부정단어의 카운터하기
-- 예제128. 스티븐 잡스 연설문에서 긍정단어가 많이 나올까 부정단어가 많이 나올까
create table positive ( p_text varchar2(2000) ) ; -- 긍정단어 table
create table negative ( n_text varchar2(2000) ) ; -- 부정단어 table
select * from speech ;
select * from positive ;
select count(*) from positive ;
select * from negative ;
select count(*) from negative ;
create or replace view speech_view
as
select regexp_substr (lower(speech_text), '[^ ]+', 1, a) word
from speech, ( select level a
from dual
connect by level <= 52 ) ;
select * from speech_view ;
select count(word) as 긍정단어
from speech_view -- 메인 쿼리
where lower(word) in ( select lower(p_text)
from positive ) ; -- 서브쿼리
-- 문제. 스티븐 잡스 연설문에서 부정단어가 몇건이나 나올까?
select count(word) as 부정단어
from speech_view
where lower(word) in ( select lower(n_text)
from negative ) ;
728x90
반응형
LIST