SQL SUM() – UCASE() FUNCTIONS

SQL SUM() FUNCTION

SQL SUM() FUNCTION

The SUM() function returns the total sum of a numeric Column.

SYNTAX

SELECT SUM(column_name) FROM table_ name

EXAMPLE

O_Id        OrderDate     OrderPrice    Customer

1             2011/11/07          1200          Johnson    

2             2011/08/15          1500            Brown

3             2011/05/04            600           Johnson  

4              2011/05/21          500            Johnson

5              2011/07/30         2500             Taylor

6              2011/10/08          300              Brown

Now we want to find the sum of all ‘Order Price” fields.

EXAMPLE

SELECT SUM(OrderPrice) AS Order Total FROM Orders

RESULT

Order Total

    6600

SQL UCASE() FUNCTION

SQL UCASE() FUNCTION

The UCASE() function Converts the value of a field to uppercase.

SYNTAX

SELECT UCASE(column_name) FROM table_name

EXAMPLE

P_Id        LastName             FirstName      Address          City

1             Jameson                   John          Streets          Sander

                                                                      15

2               Smith                       Kate           Green           Sander

                                                                       68

3            Kristensen                  Olya             Ski2             Stavn

Now we want to select the content of the “LastName” and “ FirstName” columns 

above, and convert the “LastName” column to uppercase.

EXAMPLE

SELECT UCASE(LastName) as LastName,FirstName FROM Persons

RESULT

LastName               FirstName

JAMESON                 John

SMITH                       Kate

KRISTENSEN           Olya

Leave a Reply

Your email address will not be published.