-- TOP에 수식하기
use AdventureWorks2019
select CreditCardID from sales.CreditCard
where CardType='Vista'
order by ExpYear, ExpMonth;
-- 위와 동일~ TOP 사용하여 상위 10개만 조회
select top(10) CreditCardID from sales.CreditCard
where CardType='Vista'
order by ExpYear, ExpMonth;
-- TOP에 수식하기
select top(select count(*)/100 from Sales.CreditCard) CreditCardID from sales.CreditCard
where CardType='Vista'
order by ExpYear, ExpMonth;
select top(10) * from Sales.CreditCard
where ExpYear=2008
order by ModifiedDate, ExpMonth
-- 0.1퍼센트
select top(0.1) percent CreditCardID, ExpYear, ExpMonth
from sales.CreditCard
where CardType='Vista'
order by ExpYear, ExpMonth;
select *
from Sales.SalesOrderDetail
TABLESAMPLE (5 PERCENT);
select count(*) from Sales.SalesOrderDetail;
go
'Database > MSSQL work' 카테고리의 다른 글
Merge (0) | 2020.11.09 |
---|---|
UPDATE, DELETE (0) | 2020.11.09 |
테이블에서 테이블 만들기 (0) | 2020.11.09 |
sequence , default (0) | 2020.11.09 |
판매, 고객, 상품 테이블 연습 (0) | 2020.11.09 |