DataBase
MySQL 공부4(LIMIT, MIN, MAX, COUNT, AVG, SUM)
JihyunLee
2019. 5. 3. 11:30
반응형
LIMIT
used to specify the number of records to return.
Country 가 Germany 인 customer의 정보를 3개만 가져오기
SELECT * FROM Customer WHERE Country='Germany' LIMIT 3;
MIN and MAX
used to specify the number of records to return.
product 에서 가장 가격이 가장 큰것 고르기
SELECT MAX(Price) AS LargestPrice FROM Products;
product 에서 가격이 가장 작은것 고르기
SELECT MIN(price) AS LowestPrice FROM Products;
COUNT, AVG, SUM
The COUNT() function returns the number of rows that matches a specified criteria.
The AVG() function returns the average value of a numeric column.
The SUM() function returns the total sum of a numeric column.
product 테이블에서 product의 갯수 세기
SELECT COUNT (ProductID) FROM Products;
product 테이블에서 가격의 평균내기
SELECT AVG(price) FROM Products;
OrderDetail 테이블에서 수량의 합 가져오기
SELECT SUM(Quantity) FROM OrderDetails
반응형