Oracle__5. Oracle 1Z0-051 Exam - Functions Flashcards
What will be the difference in results between these two SELECT clauses? SELECT a, count(a) FROM table GROUP BY a; SELECT a, count(*) FROM table GROUP BY a;
The first SELECT will not count any nulls in column a, while the second SELECT will count all rows
What is the simplest syntax to return all columns of a table as well as AVG(column1)?
SELECT t1., AVG(column1)FROM T1GROUP BY T1.
What function can be used in the WHERE clause if you want all records from column1 from table1 ending with an ‘n’?
WHERE SUBSTR(column,-1,1) = ‘n’
“What is the syntax if you wanted to select columns1 and column2 from table1 where column4 is greater than zero and column7 is begins with an ““A”” or ““b”” or ““C””?”
SELECT column1, column2FROM table1WHERE column4 > 0AND(SUBSTR(column7,1) = ‘A’ ORSUBSTR (column7,1) = ‘b’ORSUBSTR(column7, 1) = ‘C’)Between cannot be used because of upper/lower caseParenthesis are needed because of the AND/OR combinations
What is returned from the following statement? SELECT SUBSTR( ‘ABCdefgh’, 2, 4) FROM dual
BCde
What is returned from the following statement? SELECT SUBSTR( ‘ABCdefgh’, 5) FROM dual
efghIf the length is not specific all remaining characters are returned
What is returned from the following statement? SELECT SUBSTR( ‘ABCdefgh’, -3, 2) FROM dual
fg
Notice the spaces before and after the string, what is returned from the following statement? SELECT TRIM( ‘ Tech ‘) FROM dual
Tech spaces in front and after have been removed
What is returned from the following statement? SELECT TRIM( ‘T’ FROM ‘Tech’) FROM dual
ech
What is returned from the following statement? SELECT TRIM(LEADING ‘0’ FROM ‘0001240’) FROM dual
1240
What is returned from the following statement? SELECT TRIM(TRAILING ‘x’ FROM ‘xTechx’) FROM dual
xTech
What is returned from the following statement? SELECT TRIM( BOTH ‘1’ FROM ‘1Tech111’) FROM dual
Tech
What is returned from the following statement? SELECT RTRIM( ‘techxyxyxyxxx’, ‘xyz’) FROM dual
techThe RTRIM remove all characters that match regardless of pattern
What is returned from the following statement? SELECT LTRIM( ‘1443Tech1545’, ‘431’) FROM dual
Tech1545
What is returned from the following statement? SELECT INITCAP( ‘GEORGE BURNS’) FROM dual
George BurnsInitCap capitalizes the first letter of each word
What is returned from the following statement? SELECT UPPER( ‘GeorGe Burns 123’) FROM dual
GEORGE BURNS 123All letters are capitalized
What is returned from the following statement? SELECT LOWER( ‘GeorGe Burns 123’) FROM dual
george burns 123All letters are lower case
What is returned from the following statement? SELECT LENGTH( null) FROM dual
null
What is returned from the following statement? SELECT LENGTH( ‘’) FROM dual
null
What is returned from the following statement? SELECT LENGTH( ‘ ‘) FROM dual
1There is one space
What is returned from the following statement? SELECT LENGTH( ‘test’) FROM dual
4
What is returned from the following statement? SELECT CONCAT( ‘A’, ‘B’) FROM dual
AB
What is returned from the following statement? SELECT ‘A’ || ‘B’ FROM dual
AB
Using the CONTACT function what is the syntax for concatenating ‘A’, ‘B’ and ‘C’?
CONCAT( CONCAT( ‘A’, ‘B’), ‘C’)2 nested CONCAT Functions, because the CONCAT function can only take 2 arguments