select * from nasdaq_company where ipo_year <2021
select * from nasdaq_company where ipo_year BETWEEN 2010 AND 2021
select * from nasdaq_company where symbol between 'A' and 'B' --심볼 열에서 A나B를 포함하는 값 검색
select * from nasdaq_company where symbol not between 'A' and 'B' -- A나 B 제외 검색
select * from nasdaq_company
where symbol = 'AAPL' or symbol = 'MSFT' or symbol = 'TSLA'
select * from nasdaq_company where symbol in ('AAPL', 'MSFT', 'TSLA')
select symbol, company_name from nasdaq_company
where symbol in ('AAPL', 'MSFT', 'TSLA')
--A를 포함한 글자 다 찾기
select from nasdaq_company where symbol like '%A%'
--A로 시작하는 글자 다 찾기
select from nasdaqcompany where symbol like 'A%'
--A로 끝는 글자 다 찾기
select from nasdaq_company where symbol like '%A'
--A로 시작하지 않는글자 다 찾기
select from nasdaq_company where symbol not like 'A%'
--AA로 시작하는 글자 다 찾기
select * from nasdaq_company where symbol like 'AA%'
--A로 시작하면서 어떤 글자든 () 1자리 글자가 오고 전체가 2글자인 것 다 찾기
select from nasdaqcompany where symbol like 'A'
--A로 끝나서 어떤 글자든 (_) 1자리 글자가 앞오고 전체가 2글자인 것 다 찾기
select from nasdaqcompany where symbol like '_A'
--세글자 중 가운데 A인 것 다 찾기
select * from nasdaq_company where symbol like '_A'
--A로 시작하며 세번째는 글자가 C인 것 다 찾기
select from nasdaq_company where symbol like 'A_C%'
--A로 시작하며 C로 끝나는 4글자 다 찾기
select from nasdaqcompany where symbol like 'A__C'
--AA로 시작하면서 c 또는 p 글자 다 찾기
select from nasdaq_company where symbol like 'AA[c,p]%'
--AA로 시작하면서 L을 포함하지 않는 글자 다 찾기
select from nasdaq_company where symbol like 'AA[^L]%'
--A로 시작하면서 어떤 글자도 상관없고 마지막은 L과 어떤 한 글자 찾기
select * from nasdaq_company where symbol like 'A%L'
[]의 사용법
select from nasdaq_company where symbol like 'A[A-C]'
select from nasdaq_company where symbol like 'A[A-C, G, M-R]'
select from nasdaq_company where symbol like 'A[^A, ^B, ^C]'
select from nasdaq_company where symbol like 'A[^A-C]'
select from nasdaq_company where symbol like 'A[C,P][^T]%W'
select from nasdaq_company where symbol like 'A[A-C]_O%'
WITH CTE(col_1) AS(
SELECT 'A%BC' UNION ALL
SELECT 'A_BC' UNION ALL
SELECT 'ABC'
)
SELECT * FROM CTE WHERE col_1 LIKE '%#%%' ESCAPE '#'
select * from nasdaq_company
ORDER BY symbol desc
select * from nasdaq_company
ORDER BY ipo_year desc, symbol ASC
EXEC sp_columns @table_name =N'nasdaq_company', @table_owner = N'dbo'
select sector, industry from nasdaq_company
select symbol, close_price from nasdaq_company
select * from nasdaq_company where (sector ='Technology' or sector = 'Consumer Services')
AND symbol in ('MSFT', 'AMD', 'AMZN')
select * from nasdaq_company where sector IN('Technology', 'Consumer Services')
AND symbol in ('MSFT', 'AMD', 'AMZN')
select * from nasdaq_company where sector is null
select * from nasdaq_company where sector is not null
select * from nasdaq_company where ipo_year = 2021 and sector = 'Finance'
and symbol in('AGAC', 'TIRX', 'VLATW')
select * from nasdaq_company
select * from nasdaq_company where symbol = 'MSFT'
select * from nasdaq_company where company_name like '%apple%'
select * from nasdaq_company where symbol LIKE 'AA%[L,Q]%'
select * from nasdaq_company where close_price <= 1 and symbol not like '%^%'
select * from nasdaq_company
where symbol not like '%[-,^,=]%' and close_price <>0
order by close_price asc
select * from nasdaq_company
where close_price >=10 and close_price <=20 and
company_name not like '%a%' and ipo_year >= '2017'
order by close_price desc, ipo_year asc