절대값

select abs(-78) as a, abs(+78) as b;


반올림

select round(4.875, 1) as round;


고객별 평균 주문 금액을 백원 단위로 반올림

select custid "고객번호", round(sum(saleprice)/count(*), -2) "평균금액"

from Orders

group by custid;


문자열 치환

select bookid, replace(bookname, '야구', '농구') bookname, publisher, price

from Book;


성씨별 인원 추출

select substring(name, 1, 1) "성", count(*) "인원"

from Customer

group by substring(name, 1, 1)

========================================

select left(name, 1) "성", count(*) "인원"

from Customer

group by substring(name, 1, 1)



'programing > SQL Server' 카테고리의 다른 글

SQL Server로 배우는 데이터베이스 개론과 실습  (0) 2018.02.01

SQL Server로 배우는 데이터베이스 개론과 실습


사이트 : http://dblab.duksung.ac.kr/mssql/index.html

'programing > SQL Server' 카테고리의 다른 글

숫자함수 문자함수  (0) 2018.02.01

+ Recent posts