SQL Server MIN function
SQL Server MIN function finds lowest/least element from numeric values, finds the lowest value in
collating Sequence for character columns. gets Minimum date from date
column values
MIN(Sal) on Emp table
EMPNO | ENAME | JOB | MGR | HIREDATE | SAL | COMM | DEPTNO |
7369 | SMITH | CLERK | 7902 | 12/17/1980 12:00:00 AM | 800.00 | 20 | |
7499 | ALLEN | SALESMAN | 7698 | 2/20/1981 12:00:00 AM | 1600.00 | 300.00 | 30 |
7521 | WARD | SALESMAN | 7698 | 2/22/1981 12:00:00 AM | 1250.00 | 500.00 | 30 |
7566 | JONES | MANAGER | 7839 | 4/2/1981 12:00:00 AM | 2975.00 | 20 | |
7654 | MARTIN | SALESMAN | 7698 | 9/28/1981 12:00:00 AM | 1250.00 | 1400.00 | 30 |
7698 | BLAKE | MANAGER | 7839 | 5/1/1981 12:00:00 AM | 2850.00 | 30 | |
7782 | CLARK | MANAGER | 7839 | 6/9/1981 12:00:00 AM | 2450.00 | 10 | |
7839 | KING | PRESIDENT | 11/17/1981 12:00:00 AM | 5000.00 | 10 | ||
7844 | TURNER | SALESMAN | 7698 | 9/8/1981 12:00:00 AM | 1500.00 | 0.00 | 30 |
7900 | JAMES | CLERK | 7698 | 12/3/1981 12:00:00 AM | 950.00 | 30 | |
7902 | FORD | ANALYST | 7566 | 12/3/1981 12:00:00 AM | 3000.00 | 20 | |
7934 | MILLER | CLERK | 7782 | 1/23/1982 12:00:00 AM | 1300.00 | 10 |
Query: Select Min salary from the Employees Table
select Min(sal) from emp;
O/P:
800.00
select Min(sal) as "MinimumSalary" from emp;
O/P:
"Minimum Salary"
800.00
Query: Select Minimum salary from Dept No 10:
select Min(sal) from emp where deptno=10;
O/P: 1300.00
Query: Get Minumum Salary from each Dept..
select deptno,Min(sal) "Dept Minimum Salary" from emp group by deptno;
O/P :
deptno Dept Minimum Salary
10 1300.00
20 800.00
30 950.00
Tags:SQL-Server MIN function, SQL Server MIN function, SQL Server Aggregate function, SQL Server 2012 MIN function,using MIN in T-SQL,using MIN in Select,using MIN in Having,MIN in T-SQL
No comments:
Post a Comment