DB2 Final Answer List 2

download DB2 Final Answer List 2

of 25

Transcript of DB2 Final Answer List 2

  • 7/30/2019 DB2 Final Answer List 2

    1/25

    PETS

    PET_NAME

    OWNER_NAME

    PET_TYPE

    VARIETYBIRTH_DATE

    WEIGHT

    Spike CT Simpson Dog Yorkie 2004-12-10 8

    Mia Arnold Robbins DogChihuahua 2006-09-15 15

    Patches Ronnie Ames Cat Calico 1998-04-12 12

    Cosmo Timmy Turner Fish Beta null .3

    Spooky Arnie Marx CatMixedBreed

    2003-10-31 10

    SELECT *from PETS

    What do you add inorder to limit the abovequery's results to onlycats?

    WHERE PET_TYPE =

    'Cat'WHERE PET_TYPE NOT ='Dog'

    WHERE PET_TYPE LIKE'Ca*'

    WHERE VARIETY =

    'Calico'

    WHERE WEIGHT < 13

    restaurants

    rest_idname phone

    001 Bert's Beans 817-555-1212

    002 Herb's Ham Heaven 202-555-1779

    003 Java Shakes 202-555-2188

    004 Cattle Baron 817-555-9989

    menu_items

    rest_iditem_idmenu_item price

    001 100 Bean Soup 2.00

    001 200 Three Bean Salad 2.50

    002 300 Ham and Bean Soup 2.00

    002 310 Ham Dinner 7.00

    002 120 Pork Chop 5.00

    003 500 Coffee Cake 4.00

    004 700 Ribeye 21.00

    004 710 KC Strip 24.00

    004 720 Steak Sandwich 11.00

    SELECT menu_item, priceFROM menu_itemsWHERE rest_id IN (SELECT rest_id

    FROM restaurants

    WHERE SUBSTR(phone,1,3) = '817')

    How many rows does the above query return?

    1

    2

    3

    4

  • 7/30/2019 DB2 Final Answer List 2

    2/25

    5

    Considering the above PETS table definition, what database object do you use to enforce a rule that theonly types of pets allowed are cats and dogs?

    A trigger to check values being inserted

    A User Defined Function defined on TYPE

    An index on the TYPE field

    A column constraint defined on TYPE

    A column constraint defined on OWNER_NAME

    The above diagram describes three related tables. Which statement do you use to list allof the employees who are now or have been assigned to JOB_ID 1234?

    SELECT EMP_LAST_NAME

    FROM Employee E INNER JOIN(Job_Assignment A LEFT JOIN

    Job_Assignment P ON A.JOB_ID = P.JOB_IDHAVING A.JOB_ID = '1234' or P.JOB_ID = '1234')

    ON E.EMP_ID = A.EMP_ID

    SELECT EMP_LAST_NAME FROM Employee E LEFT JOIN(Job_Assignment A LEFT JOINJob_Assignment P on A.JOB_ID = P.JOB_ID)on E.EMP_ID = A.EMP_ID

  • 7/30/2019 DB2 Final Answer List 2

    3/25

    WHERE A.JOB_ID = '1234' or P.JOB_ID = '1234'

    SELECT EMP_LAST_NAMEFROM Employee E LEFT OUTER JOIN

    Job_Assignments AON E.EMP_ID = A.EMP_IDWHERE A.JOB_ID = '1234' or PRIOR_JOB_ID = '1234'

    SELECT EMP_LAST_NAME FROM Employee E INNER JOINJob_Assignment A

    ON E.EMP_ID = A.EMP_IDWHERE A.JOB_ID = '1234' or PRIOR_JOB_ID = '1234'

    SELECT EMP_LAST_NAMEFROM Employee E INNER JOIN

    (Job_Assignment A LEFT JOIN

    Jobs J on A.JOB_ID = J.JOB_ID)on E.EMP_ID = A.EMP_ID

    WHERE A.JOB_ID = '1234' or J.JOB_ID = '1234'

    After the above cursor is opened and a row fetched, how do you update the selected employee's salary by 5percent?

    UPDATE EMPLOYEESET EMP_SALARY = EMP_SALARY * 1.05WHERE EMP_ID = :emp-id

    SET EMP_SALARY = EMP_SALARY * 1.05WHERE CURRENT OF EMP_CURSOR

    UPDATE EMP_CURSOR

    SET EMP_SALARY = EMP_SALARY * 1.05

    No additional code is needed.

    UPDATE EMPLOYEESET EMP_SALARY = EMP_SALARY * 1.05WHERE CURRENT OF EMP_CURSOR

  • 7/30/2019 DB2 Final Answer List 2

    4/25

    Referring to the above definition of the EMPLOYEE table, which WHERE clause do you use to return allrecords from EMPLOYEE with last names starting with the letters "AR"?

    WHERE EMP_LAST_NAME = "AR*"

    WHERE EMP_LAST_NAME LIKE 'AR'

    WHERE LEFT(EMP_LAST_NAME) = 'AR'

    WHERE EMP_LAST_NAME LIKE 'AR%'WHERE EMP_LAST_NAME LIKE 'A%'

    Which WHERE clause do you need to add to the above query so that only employees with NULL term datesare returned?

    WHERE ISNULL(TERM_DT) = "TRUE"

    WHERE TERM_DT = ""

    WHERE TERM_DT IS NULL

    WHERE NULL(TERM_DT)

    WHERE TERM_DT = NULL

  • 7/30/2019 DB2 Final Answer List 2

    5/25

    In the above scenario, what locking change occurs when the UPDATE statement executes?

    The lock type changes from S (share) to X (exclusive).

    The lock type changes from X (exclusive) to U (intent update).

    The lock type changes from U (intent update) to X (exclusive).

    The lock type changes from I (intent share) to U (intent update).

    The lock type changes from S (share) to U (intent update).

    In the above database, when an Owner's name needs to be changed, what process do you follow?

    Delete the OWNER record with the old name, insert a new OWNER record with the new name, and update the PETS records with

  • 7/30/2019 DB2 Final Answer List 2

    6/25

    the new name.

    Update the PETS records with the new name, then update the OWNERS table with the new name.

    Insert a new OWNER record with the new name, update the PETS records with the new name, and delete the original OWNERrecord.

    Insert a new OWNER record with the new name, delete the original OWNER record, and update the PETS records with the newname.

    Issue an UPDATE command on OWNERS setting HUMAN_NAME = 'newname' WHERE HUMAN_NAME = 'oldname'.

    EVENTS

    event_name event_date event_type ticket_price

    Boston Symphony 2008-07-04 Concert 32.00

    Back To School Party 2008-08-25 Church 2.00

    Carrie Underwood 2008-09-02 Concert 26.00

    Fall Festival 2008-10-29 Family 2.00

    Valentine Dance 2008-02-14 Dance 17.00

    New Years Eve Ball 2008-12-31 Dance 45.00

    Dog Show 2009-01-12 Family 8.00

    DECLARE event_list SENSITIVE STATIC SCROLL CURSOR forSELECT event_nameFROM eventsORDER BY event_date;

    OPEN event_list;

    FETCH ABSOLUTE 2 into :hv_event;

    FETCH ABSOLUTE 3 into :hv_event;

    What is the value of hv_event when you execute the above sequence of DECLARE, OPEN, and both FETCH statements?

    NULL

    Back To School Party

    Carrie Underwood

    Dog Show

    Valentine Dance

  • 7/30/2019 DB2 Final Answer List 2

    7/25

    Which one of the following nested table expressions do you add to the FROM clause in the above query to supply the average

    boat length for each owner's fleet?

    (SELECT VESSEL_NAME,AVG(VESSEL_LENGTH) as VESSEL_AVG

    FROM BOATSGROUP BY VESSEL_NAME) as M

    (SELECT OWNER_NAME,AVG(VESSEL_LENGTH) as VESSEL_AVG

    FROM BOATSGROUP BY VESSEL_LENGTH) as M

    (SELECT OWNER_NAME,AVG(VESSEL_LENGTH) as VESSEL_AVG

    FROM BOATSGROUP BY OWNER_NAME) as M

    (SELECT OWNER_NAME,MAX(VESSEL_LENGTH) as VESSEL_MAX

    FROM BOATSGROUP BY OWNER_NAME) as M

    (SELECT OWNER_NAME,MAX(VESSEL_LENGTH) as VESSEL_AVG

    FROM BOATS

    GROUP BY OWNER_NAME) as M

    PETS

    PET_NAME OWNER_NAME PET_TYPE VARIETY BIRTH_DATE WEIGHT

    Spike CT Simpson Dog Yorkie 2004-12-10 8

    Mia Arnold Robbins Dog Chihuahua 2006-09-15 15

    Patches Ronnie Ames Cat Calico 1998-04-12 12

  • 7/30/2019 DB2 Final Answer List 2

    8/25

    Cosmo Timmy Turner Fish Beta null .3

    Spooky Arnie Marx Cat Mixed Breed 2003-10-31 10

    In the above PETS table, how do you return the total weight for each type of pet?

    SELECT PET_TYPE, COUNT(WEIGHT)

    FROM PETSGROUP BY PET_TYPE

    SELECT PET_TYPE, WEIGHTFROM PETSGROUP BY PET_TYPESUM BY WEIGHT

    SELECT PET_TYPE, SUM(WEIGHT)FROM PETSGROUP BY PET_TYPE

    SELECT PET_TYPE, SUM(WEIGHT)FROM PETSORDER BY PET_TYPE

    SELECT PET_TYPE, WEIGHT

    FROM PETSSUM WEIGHT BY PET_TYPE

    Which predicate clause in the above query is NOT a stage 1 predicate?

    CUSTOMER_ID = :hv_cust_id

    EST_SHIP_DT < current date - 30 days

    ACT_SHIP_DT BETWEEN ORDER_DT and EST_SHIP_DT

  • 7/30/2019 DB2 Final Answer List 2

    9/25

    CUST_PD_DT is NULL

    ORDER_TYPE = 'B'

    PETSPET_NAME OWNER_NAME PET_TYPE VARIETY BIRTH_DATE WEIGHT

    Spike CT Simpson Dog Yorkie 2004-12-10 8

    Mia Arnold Robbins Dog Chihuahua 2006-09-15 15

    Patches Ronnie Ames Cat Calico 1998-04-12 12

    Cosmo Timmy Turner Fish Beta null .3

    Spooky Arnie Marx Cat Mixed Breed 2003-10-31 10

    SELECT COUNT(*),COUNT(DISTINCT PET_TYPE)

    FROM PETS

    What values does the above query return?

    5, 5

    3, 5

    5, null

    5, 3

    3, 3

    The above diagram shows the definition of three related tables. If the delete rule for these tables is ON DELETE CASCADE, whathappens when you delete a record from the Jobs table?

    The Jobs record, all Job Assignment records for that JOB_ID, and all Employee records associated with those jobs are deleted.

    All records are deleted from the Jobs table.

    The Jobs record and all Job Assignment records for that JOB_ID are deleted.

    An error is returned; you are required to delete the related Job Assignment records before deleting the Jobs record.

    The Jobs record is deleted; no other records are affected.

  • 7/30/2019 DB2 Final Answer List 2

    10/25

    employees

    first_name last_name salary

    Carl Spellman 60000.00

    Ron Rinkle 50000.00

    Art Todd 40000.00

    Amy Walters 45500.00

    Ken Reyes 60400.00

    Martin Johnson 50600.00

    markets

    location avg_salary

    N 40000.00

    S 30000.00

    NE 40000.00

    NW 30000.00

    SE 40000.00

    SELECT last_name, first_name, salaryFROM employeesWHERE salary IN

    (SELECT avg_salaryFROM marketsWHERE location IN ('N', 'S'))

    How many rows does the above SQL statement return?

    0

    1

    2

    3

    4

    PETS

    PET_NAME OWNER_NAME PET_TYPE VARIETY BIRTH_DATE WEIGHT

    Spike CT Simpson Dog Yorkie 2004-12-10 8

    Mia Arnold Robbins Dog Chihuahua 2006-09-15 15

    Patches Ronnie Ames Cat Calico 1998-04-12 12

    Referring to the above table, how do you change Mia's record to show that she now weighs 18 pounds?

    UPDATE MiaSET WEIGHT = 18FROM PETS

    UPDATE PETS.WEIGHT(Mia) = 18

    SET PETS.WEIGHT = 18WHERE PET_NAME = 'Mia'

    MODIFY PETSSET WEIGHT = 18WHERE PET_NAME = 'Mia'

    UPDATE PETSSET WEIGHT = 18WHERE PET_NAME = 'Mia'

  • 7/30/2019 DB2 Final Answer List 2

    11/25

    In the above Job Assignment and Employee tables, what is the effect of the Foreign Key relationship between the EMP_IDcolumns?

    Every Employee record must have an EMP_ID that exists in Job Assignment.

    When adding records to Job Assignment, records are automatically created in Employee.

    Every Job Assignment record must have an EMP_ID that exists in Employee.

    When adding records to Employee, records are automatically created in Job Assignment.

    Matching records must be inserted to the two tables within the same INSERT statement.

  • 7/30/2019 DB2 Final Answer List 2

    12/25

    Considering the PETS table definition listed above, what causes the provided INSERT statement to fail?

    The value '18' should not be in quotes.

    NULL is not allowed in an INSERT statement.

    Double quotes are required for CHAR data.

    The value list does not include an entry for 'BIRTH_DATE'.

    Spaces are only allowed in VARCHAR fields.

    Table Name: vtable

    Column Name Null/Not Null Data Type

    a not null integer

    b null char(50)

    c null integer

    d not null char(100)

    Referring to the table above, which one of the following SQL statements is valid?

    SELECT FROM vtable WHERE a = 5SELECT a, b, AND c FROM vtable

    SELECT * WHERE vtable.b = "bvalue"

    SELECT a TO d FROM vtable WHERE c IS NULL

    SELECT a * c FROM vtable

    After the above cursor is opened and a row is fetched, how do you delete the row?

    OLD_EMP.DELETE

    DELETE WHERE CURRENT OF OLD_EMP

    DELETE FROM EMPLOYEEWHERE CURRENT OF OLD_EMP

    DELETE FROM CURRENT OF OLD_EMP

    DELETE OLD_EMP

  • 7/30/2019 DB2 Final Answer List 2

    13/25

    animals

    name family

    dog mammal

    lion mammal

    guppy fisheagle bird

    guppy fish

    pelican bird

    bass fish

    types

    family blood_temp

    mammal warm

    fish cold

    bird warmreptile cold

    SELECT nameFROM animals aWHERE EXISTS (SELECT 1

    FROM types tWHERE t.family = a.family

    AND t.family LIKE 'b%')

    How many rows does the above query return?

    1

    2

    4

    5

    7

    Considering the above table, what special register value do you use in your insert or update statement to set the acct_chg_tmstp?

    CURRENT TIMESTAMP

    CURRENT DATE

    NOW()

    TIMESTAMP(now)

    TIMESTAMP(current date, '00.00.00')

  • 7/30/2019 DB2 Final Answer List 2

    14/25

    Which one of the following FROM clauses do you add to the above query to show the percentage of each owner's fleet that isabove his fleet's average gross tonnage?

    FROM (SELECT OWNER_NAME,AVG(VESSEL_GROSS_TONS) AS AVG_TONS

    FROM BOATSGROUP BY OWNER_NAME) AS A,

    BOATS B

    FROM (SELECT OWNER_NAME,COUNT(*) AS FLEET_COUNT

    FROM BOATSGROUP BY OWNER_NAME AS A,

    BOATS B

    FROM (SELECT OWNER_NAME,COUNT(*) AS FLEET_COUNT,

    AVG(VESSEL_GROSS_TONS) AS AVG_TONSFROM BOATSGROUP BY VESSEL_NAME) AS A,

    BOATS B

    FROM (SELECT VESSEL_NAME,COUNT(*) AS FLEET_COUNT,AVG(VESSEL_GROSS_TONS) AS AVG_TONS

    FROM BOATSGROUP BY VESSEL_NAME) AS A,

    BOATS B

    FROM (SELECT OWNER_NAME,COUNT(*) AS FLEET_COUNT,AVG(VESSEL_GROSS_TONS) AS AVG_TONS

    FROM BOATSGROUP BY OWNER_NAME) AS A,

    BOATS B

    EVENTS

    event_name event_date event_type ticket_price

  • 7/30/2019 DB2 Final Answer List 2

    15/25

    Fall Festival 2008-10-29 Family 2.00

    Boston Symphony 2008-07-04 Concert 32.00

    Carrie Underwood 2008-09-02 Concert 26.00

    Valentine Dance 2008-02-14 Dance 17.00

    New Year's Ball 2008-12-31 Dance 15.00

    Dog Show 2009-01-12 Family 8.00

    SELECT *FROM EVENTSWHERE event_date between '2008-09-01' and '2008-12-31'

    AND ticket_price

  • 7/30/2019 DB2 Final Answer List 2

    16/25

    In the above query, what WHERE clause do you add to select all the orders in the ORDERS table for customers that have orders in

    the ORDER_ARCHIVE table?

    WHERE CUSTOMER_ID IN(SELECT 1FROM ORDER_ARCHIVE AWHERE O.CUSTOMER_ID = A.CUSTOMER_ID)

    WHERE EXISTS(SELECT 1FROM ORDER_ARCHIVE AWHERE O.CUSTOMER_ID = A.CUSTOMER_ID)

    WHERE EXISTS CUSTOMER_ID IN

    (SELECT 1FROM ORDER_ARCHIVE AWHERE O.CUSTOMER_ID = A.CUSTOMER_ID)

    WHERE CHECK(SELECT 1FROM ORDER_ARCHIVE AWHERE O.CUSTOMER_ID = A.CUSTOMER_ID)

    WHERE ANY CUSTOMER_ID IN(SELECT 1FROM ORDER_ARCHIVE AWHERE O.CUSTOMER_ID = A.CUSTOMER_ID)

  • 7/30/2019 DB2 Final Answer List 2

    17/25

    If acct_no in theabove table isdefined asGENERATEDALWAYS ASIDENTITY, whichone of thefollowingstatements doyou use to inserta newACCOUNTSrecord?

    INSERT INTOACCOUNTS(acct_no,acct_type,acct_chg_tmstp)VALUES(NEXT(acct_no),'Checking',currenttimestamp)

    INSERT INTOACCOUNTS(acct_no,

    acct_type,acct_chg_tmstp)VALUES(NEXTVAL foracct_no,'Checking',currenttimestamp)

    INSERT INTOACCOUNTS(acct_no,acct_type,acct_chg_tmstp)VALUES (NEXTacct_no,'Checking',currenttimestamp)

    INSERT INTOACCOUNTS(acct_type,acct_chg_tmstp)VALUES

  • 7/30/2019 DB2 Final Answer List 2

    18/25

    ('Checking',currenttimestamp)

    INSERT INTOACCOUNTS(acct_no,acct_type,acct_chg_tmstp)VALUES (NEXTIDENTITY,'Checking',currenttimestamp

    What type of database object do you create if you want to reduce network traffic?

    Trigger

    User-definedfunction

    Constraint

    View

    Storedprocedure

    An update program is locking enough data to cause lock escalation, but adding COMMIT statements is not an acceptable option.

    How do you prevent the overhead of lock escalation in this situation?

    Change the order in which your program accesses the data.

    Add the LOCK TABLE instruction to the program.

    Ensure that the program uses Repeatable Read (RR) isolation.

    Add the SET MAXLOCKS instruction to your program.

    Add the SET LOCKESC= -1 instruction to your program.

    Table A

    fname

    lname

    idnumber

    Table B

    idnumber

    salary

    startdate

    Referring to the tables above, which one of the following phrases do you use to return all of the rows from table A and anycorresponding rows from table B?

    INNER JOIN

    LEFT JOIN

    IF EXISTS

    CROSSREF

    JOIN NULL

    What query do you use to determine information about the indexes defined on the table named

  • 7/30/2019 DB2 Final Answer List 2

    19/25

    "your_table"?

    SELECT *FROMSYSIBM.TABLEINDEXESWHERE TABLENAME ='your_table'

    SELECT INDEXNAME,INDEXDEFFROM SYSIBM.SYSTABLESWHERE TBNAME ='your_table'

    SELECT *FROMSYSIBM.SYSINDEXES

    WHERE TBNAME ='your_table'

    SELECT INDEX_DEFFROM your_table

    SELECT *FROM

    SYSIBM.SYSINDEXDEFWHERE TBNAME ='your_table'

    CREATE PROCEDURE add_three (IN a1 INTEGER,IN a2 INTEGER,IN a3 INTEGER,OUT s1 INTEGER)

    LANGUAGE SQLSPECIFIC add_three

    BEGINSET s1 = a2+a2+a3;

    END

    Referring to the above proceduredefinition, which one of the following callsis valid?

    CALL add_three(1, 2, 3, 4)

    CALL add_three(1, 2, 4)

    CALL add_three(1, 2, 3, ?)

    CALL add_three(a, b, current date, ?)

    CALL add_three(1.2, 3, 4, ?)

  • 7/30/2019 DB2 Final Answer List 2

    20/25

    Referring the the above ACCOUNTS table, which WHERE clause do you use if you want to select only the records that werechanged yesterday?

    WHERE acct_chg_tmstp >= current timestamp - 1 day

    WHERE acct_chg_tmstp = current date - 1 day

    WHERE acct_chg_tmstp = current timestamp - 1 day

    WHERE DATE(acct_chg_tmstp) = current date - 1 day

    WHERE DATE(acct_chg_tmstp) > current date - 1 day

    When handling errorconditions, programsmay implement"retry" logic toattempt theoperation againbefore failing.

    Which one of the following error conditions justifies retry logic as described above?

    Deadlock or timeout

    Row not found

    Duplicate key violation

    Value incompatible with column's data type

    Insufficient authorization

    The above Pet Club data tables are related through the HUMAN_NAME fields. What result do you get fromthe above SELECT query?

    Each pet owner and his/her address

    A single record is returned for each pet owner; whichever pet was listed first in the PETS table is shown.

    You get no result; the statement is not valid. (CHECK)

    Each pet and its owner

    Every pet and it's address

    Which one of the following do you use to place the value of today's dateinto the variable "program_date"?

    set program_date = run_date

  • 7/30/2019 DB2 Final Answer List 2

    21/25

    set program_date = current date

    set program_date = now()

    set program_date = current timestamp

    set program_date = date(today)

    Which fields do you include in an index if you want to optimize performance of the above query?

    CUSTOMER_ID, ORDER_DT, CUST_PD_DT

    CUSTOMER_ID, ORDER_DT, ACT_SHIP_DT, BILL_AMT

    CUSTOMER_ID, CUST_PD_DT

    ORDER_ID, ORDER_DT

    CUSTOMER_ID, ORDER_DT

    PETS

    PET_NAME OWNER_NAME PET_TYPE VARIETY BIRTH_DATE WEIGHT

    Spike CT Simpson Dog Yorkie 2004-12-10 8

    Mia Arnold Robbins Dog Chihuahua null 15Patches Ronnie Ames Cat Calico 1998-04-12 12

    Cosmo Timmy Turner Fish Beta null .3

    Spooky Arnie Marx Cat Mixed Breed 2003-10-31 10

    Pepper Arnie Marx Dog Great Dane 2001-01-29 56

    SELECT PET_NAME,COALESCE(BIRTH_DATE, '9999-12-31')

    FROM PETS

  • 7/30/2019 DB2 Final Answer List 2

    22/25

    WHERE PET_TYPE = 'DOG'

    What is the result of the above query?

    Spike 2004-12-10Mia 9999-12-31Spooky 2003-10-31

    Pepper 2001-01-29

    Spike 2004-12-10Mia 2004-12-10Pepper 2001-01-29

    Spike 9999-12-31Mia 9999-12-31Pepper 9999-12-31

    Spike 2004-12-10Mia 9999-12-31Pepper 2001-01-29

    Spike 2004-12-10Mia nullPepper 2001-01-29

    What do you need to add to the above query if you want to produce a sorted list, with newest first, of how many employees werehired on each date?

    SUM BY EMP_HIRE_DT

    ORDER BY EMP_HIRE_DT DESC

    ORDER BY EMPLOYEECOUNT BY EMP_HIRE_DT

    GROUP BY EMP_HIRE_DTORDER BY EMP_HIRE_DT DESC

  • 7/30/2019 DB2 Final Answer List 2

    23/25

    COUNT BY EMPLOYEEORDER BY EMP_HIRE_DT

    GROUP BY EMP_HIRE_DT

    A dynamic SQL statement is executed many times with different valued variables each time.

    Referring to the above scenario, how do you prepare the statement to use the same access path at each execution?

    PREPARE using the maximum values of each variable.

    PREPARE using ? as a parameter marking.

    PREPARE using % as a parameter marking.

    BIND using the DYNAMIC(REUSE) option.

    Add the WITH UR clause to the statement.

    products

    name price type

    soap 2.00 C

    floss 2.00 D

    brush 3.00 A

    SELECT name, COUNT(price)FROM productsWHERE type BETWEEN 'A' AND 'D'

    Which one of the followingdo you use to completethe above query?

    GROUP BY type

    GROUP BY name (CHECK)

    GROUP BY price

    GROUP BY COUNT(price)

    GROUP BY 1

    ACCOUNTacc_no acc_type amount--------- ---------- ---------

    10 c 356.1231 m 1387.6425 c 12500.0022 m 40356.1561 c 12500.00

    SELECT acc_type, amount, 'small' ascategory1FROM ACCOUNTWHERE amount

  • 7/30/2019 DB2 Final Answer List 2

    24/25

    UNION

    SELECT acc_type, amount, 'big' ascategory2FROM ACCOUNTWHERE amount >= 10000ORDER BY amount,acc_type

    Referring to the above table, how many rows does the query return?

    None, the columns in the SELECTs do not match, which causes an error.

    None, WHERE cannot intersect.

    None, ORDER BY in the first SELECT causes an error.

    Three rows

    Five rows (CHECK)

    Table Definition

    Referring to the above ACCOUNTS table, how do you convert the acct_chg_dt and acct_chg_tm fields into a single timestamp value?

    Choice 1TIMESTAMP(acct_chg_dt, acct_chg_tm, '000000')

    Choice 2TIMESTAMP(acct_chg_dt + acct_chg_tm)

    Choice 3TIMESTAMP(acct_chg_dt, acct_chg_tm)

    Choice 4CAST(acct_chg_dt, acct_chg_tm) as TIMESTAMP

    Choice 5CAST(acct_chg_dt || acct_chg_tm) as TIMESTAMP

    ScenarioClients

    cno fname lname city state tax----------- ---------- ---------- ---------- ----- --------

    10 Rachel Wise Fair Lawn NJ 7.0020 Michael Strong FLINT MI 8.0030 Mario Subrutini NC 6.0040 Mark Shine Two Oaks 5.0050 David D'Ark Chicago IL

    SELECT fname || lname || ' from ' || city || ', ' || stateFrom clientsWHERE tax > 0

    Referring to the Clients table above, what is the result of the query?

    Choice 1

    Rachel Wise from Fair Lawn, NJMichael Strong from FLINT, MINULLNULLChoice 2Rachel Wise from Fair Lawn, NJ

    Michael, Strong from FLINT, MIChoice 3Rachel Wise from Fair Lawn, NJ

    Michael Strong from FLINT, MINULLNULL

  • 7/30/2019 DB2 Final Answer List 2

    25/25

    David D'Ark from Chicago, ILChoice 4Rachel Wise from Fair Lawn, NJ

    Michael Strong from FLINT, MIDavid D'Ark from Chicago, ILChoice 5Rachel Wise from Fair Lawn, NJ

    Michael Strong from FLINT, MI

    NULLNULLNULL

    For Not Found Condition :

    SQLCODE : +100SQLSTATE : 02000