SQL Scalar Functions
- CHAR
- DATE
- SUBSTR
- DAYS
- DECIMAL
- DIGITS
Literals
- CURRRENT DATE
- CURRENT TIME
- TIMESTAMP
- NULL (is/is not)
Examples
- DECIMAL(SALARY/52,9,2)
- INTEGER(HOURLYRATE
- COUNT(DISTINCT DEPT)
- DAY(DATE(CURRENT DATE) - DATE('2003-01-01'))
Selection Statements
- SELECT
- FROM
- WHERE
- GROUP BY
- HAVING
- ORDER BY
Sample
Select DEPT, count(DEPT), decimal(avg(SALES),7,2)
from XYZFILE group by DEPT
Sample Case
Select substr(digits(day(current date)),9,2) ||
(case month(current date)
when 01 then 'JAN'
when 02 then 'FEB'
when 03 then 'MAR'
when 04 then 'APR'
when 05 then 'MAY'
when 06 then 'JUN'
when 07 then 'JUL'
when 08 then 'AUG'
when 09 then 'SEP'
when 10 then 'OCT'
when 11 then 'NOV'
else 'DEC' end)
substr(digits(year(current date)),9,2)
from XYZFILE
Back to Main Page | Contact Info