Saturday 3 December 2011

SQL Max() and Min()

                                         

                                                                   SQL MAX()


The MAX() function returns the largest value of the selected column.

SQL MAX() Syntax

SELECT MAX(column_name) FROM table_name

 The "custmast" table

custcode
custname
city
qty
rate
1
Siva
Srivilliputtur
50
70
2
Bala
Sivakasi
30
56
3
Kanna
Madurai
100
200
4
Vijay
Chennai
30
30
5
Kodee
Sandnes
60
80
5
Kodee
Srivilliputtur
60
30


Example : 

SELECT MAX(Qty) as MaxQty FROM custmast

MaxQty 
         100 



                                                                 SQL MIN()


The MIN() function returns the smallest value of the selected column.

Syntax

SELECT MIN(column_name) FROM table_name

Example :

SELECT MIN(Qty) as MINQTY FROM custmast

        MINQTY 
           30 


0 comments:

Post a Comment

Followers

Powered by Blogger.