marți, 26 februarie 2013

PROGRAMMING: Section 1

CASE AND CARACTER MANIPULATION
Identify the output from the following SQL statement:
SELECT RPAD('SQL',6, '*')
FROM DUAL;
SQL***

Which query selects the first names of the DJ On Demand clients who have a first name beginning with "A"?
SELECT UPPER(first_name)
FROM d_clients
WHERE LOWER(first_name) LIKE 'a%'

Which character manipulation function always returns a numerical value?
LENGTH

What does the following SQL SELECT statement return?
SELECT UPPER( SUBSTR('Database Programming', INSTR('Database Programming','P'),20))
FROM dual;
PROGRAMMING

Which of the following SQL statements would correctly return a song title identified in the database as "All Thesears"?     
WHERE title LIKE INITCAP('%all these years');

Which of the following are types of SQL functions?
Multi-Row Functions
Single-Row Functions

Character functions accept character arguments and only return character values. True or False?
False
       
Which query would return a user password combining the ID of an employee and the first 4 characters of the last name?
SELECT CONCAT (employee_id, SUBSTR(last_name,1,4))
AS "User Passwords"
FROM employees


NUMBER FUNCTIONS
The answer to the following script is 456. True or False?
SELECT TRUNC(ROUND(456.98))
FROM dual
False
          
Which number function may be used to determine if a value is odd or even?
MOD
           
What is the result of the following SQL Statement:
SELECT ROUND(45.923,-1)
FROM DUAL;
50
          
ROUND and TRUNC functions can be used with which of the following Datatypes?
Dates and numbers
          

DATE FUNCTIONS
What is the result of the following query?
SELECT ADD_YEARS ('11-JAN-94',6)
FROM dual;
This in not a valid SQL statement.
          
What function would you use to return the highest date in a month?
LAST_DAY
          
Which query would return a whole number if the sysdate is 26-MAY-04?
SELECT TRUNC(MONTHS_BETWEEN(SYSDATE,'19-MAR-79') /12)
AS YEARS
FROM DUAL;
          
If hire_date has a value of '03-July-03', then what is the output from this code
SELECT ROUND(hire_date, 'Year') FROM employees;
01-JAN-04
          
Round and Trunc can be used on Date datatypes. True or False?
True
         
What is the result of the following query?
SELECT ADD_MONTHS ('11-JAN-94',6)
FROM dual;
11-JUL-1994

Niciun comentariu:

Trimiteți un comentariu