SQL Quiz 2: Functions

10 Questions | Total Attempts: 725

SettingsSettingsSettings
Please wait...
SQL Quizzes & Trivia

Functions(Char,Concat,Substr etc) Date Functions Numeric Functions(Sum,Avg etc) Usage of group by and Having with aggregate functions Use of IFNull and Coalease functions Case expression


Questions and Answers
  • 1. 
    Which one of the following queries will select the Number of Unique Departments from the Department Table below Department Number               Employee Number 11 248525 11 267712 12 112456 11 234567 13 661231
    • A. 

      Select count(*) from Department_Table

    • B. 

      Select count(distinct DepartmentNumber) from Department_Table having distinct DepartmentNumber

    • C. 

      Select count(distinct DepartmentNumber) from Department_Table

    • D. 

      Select distinct departmentNumber from Department_Table

  • 2. 
    The output from the function dec(-99.9999) would be
    • A. 

      -99.9999

    • B. 

      -99

    • C. 

      99.9999

    • D. 

      99

  • 3. 
    How to display Number of days from today for a given date(2012-07-31)
    • A. 

      Select date(‘2012-07-31’) – curdate() from sysibm/sysdummy1

    • B. 

      Select ‘2012-07-31’ – date(curdate()) from sysibm/sysdummy1

    • C. 

      Select ‘2012-07-31’ – curdate() from sysibm/sysdummy1

    • D. 

      Select date(‘2012-07-31’) – date(curdate()) from sysibm/sysdummy1

  • 4. 
    The output of LTRIM(‘  Test Yourself’) || Strip(‘$when$ you have problem’,’B’,’$’) would be
    • A. 

      Test Yourselfwhen$you have problem

    • B. 

      Test Yourself when you have problem

    • C. 

      Test Yourself$when you have problem

    • D. 

      Test Yourself$when$you have problem

  • 5. 
     How to convert date YYYY-MM-DD to MMDDYYYY format
    • A. 

      Substr(YYYY-MM-DD,6,2) || Substr(YYYY-MM-DD,9,2) || Substr(YYYY-MM-DD,1,4)

    • B. 

      Concat(Substr(YYYY-MM-DD,9,2) , Substr(YYYY-MM-DD,6,2) , Substr(YYYY-MM-DD,1,4))

    • C. 

      Substr(YYYY-MM-DD,9,2) || Substr(YYYY-MM-DD,6,2) || Substr(YYYY-MM-DD,1,4)

    • D. 

      None of the above

  • 6. 
    The output of day(‘2008-01-12’) would be same as that of day(’12.01.2008’)
    • A. 

      True

    • B. 

      False

  • 7. 
    What would the output of coalesce(NULLIF(4500.00,4500),’1’)
    • A. 

      4500

    • B. 

      1

    • C. 

      Null

    • D. 

      Error

  • 8. 
    What would be output of the below query  Select max(min(SLSVLM)) from sales SLSVLM    SLSDate 1 20121010 12 20121110 5 20120111 2 20120111 -1 20120112 0 20120106
    • A. 

      12

    • B. 

      0

    • C. 

      -1

    • D. 

      Error

  • 9. 
    The output of the below query would be  Select  ISNULL(day(SLSDate),SUBSTR(SLSDATE,9,2)) from sales  SLSVLM    SLSDate 1 10/10/2012 12 10/11/2012 5 1/11/2012 2 1/11/2012 Note*: each value in an option is a row
    • A. 

      NULL NULL 01 01

    • B. 

      10 10 11 11

    • C. 

      NULL 11 01 01

    • D. 

      None of the above

  • 10. 
     What would be the output of STRIP(‘555Dollor55Dollor555’,B,’5’)
    • A. 

      55Dollor55Dollor55

    • B. 

      Dollor55Dollor55

    • C. 

      Dollor55Dollor

    • D. 

      DollorDollor

Related Topics
Back to Top Back to top