[prog] SQL - MSSQL2020. 12. 18. 09:21

참고 : docs.microsoft.com/ko-kr/sql/t-sql/data-types/data-types-transact-sql?view=sql-server-ver15

 

 

-- 실행 1
select max(yearlyIncome) as 최고수입
from   DimCustomer (nolock)

/***********************
실행 1 의 결과 
   최고수입
-----------
1  170000.00
***********************/

----------------------------
-- 실행 2
declare @yIncome float
select @yIncome = max(yearlyIncome)
from   DimCustomer (nolock)

select @yIncome as 최고수입

----------------------------
-- 실행 3
declare @yIncome numeric
select @yIncome = max(yearlyIncome)
from   DimCustomer (nolock)

select @yIncome as 최고수입

----------------------------
-- 실행 4
declare @yIncome decimal(10, 2)
select @yIncome = max(yearlyIncome)
from   DimCustomer (nolock)

select @yIncome as 최고수입

----------------------------
-- 실행 5
declare @yIncome numeric(10, 2)
select @yIncome = max(yearlyIncome)
from   DimCustomer (nolock)

select @yIncome as 최고수입

 

 

결과 2, 3
   최고수입
-------------
1  170000

--------------------------------------------

결과 4, 5
   최고수입
-------------
1  170000.00

 

Posted by dawnawaker