0% found this document useful (0 votes)
4 views

java 2

The document contains a series of multiple-choice questions related to SQL, including topics such as joins, aggregate functions, and SQL syntax. It tests knowledge on various SQL concepts like inner joins, outer joins, Cartesian products, and specific SQL functions. The questions also cover practical SQL queries and their expected outputs in different scenarios.

Uploaded by

H DASHA HEGDE
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

java 2

The document contains a series of multiple-choice questions related to SQL, including topics such as joins, aggregate functions, and SQL syntax. It tests knowledge on various SQL concepts like inner joins, outer joins, Cartesian products, and specific SQL functions. The questions also cover practical SQL queries and their expected outputs in different scenarios.

Uploaded by

H DASHA HEGDE
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 14

1.

How many tables may be included with a joint

A. Three

B..One

C.1Two

D.Allof thelisted options


2. To produce a meaningful result set without any Cartesian products, what is the minimum number of
conditions that should appear in the WHERE clause of a four-table join?

Select one:

8.. 4
C. 2
. 8

3. Given the following descriptions of the employees and jobs tables, which of the following scripts will
display each employee minimum and maximum salaries based on their job title?

EMPLOYEES Table
Name Null? Type

EMPLOYEE ID NOT NULL NUMBER (6)

FIRST NAME VARCHAR2


(20
LAST NAME NOT NULL VARCHAR2 (25)

EMAIL NOT NULL VARCHAR2 (25)

PHONE NUMBER VARCHAR2 (20)

HIRE DATE NOT NULL DATE

JOB ID NOT NULL VARCHAR2 (10)

SALARY NUMBER (8,2)

cOMMISSION PCT NUMBER (2,2)

MANAGER ID NUMBER (6)

DEPARTMENT ID NUMBER (4)

JOBS Table:

Name Null? Type

JOB ID NOT NULL VARCHAR2 (10)


JOB TITLE NOT NULL VARCHAR2 (35)

MIN_SALARY NUMBER (6)

MAX SALARY NUMBER (6)


Select one

A. SELECT first name, last name, job_id, min_salary, max_salary FROM employees e FULL JOIN Jjobs
job id):
B. SELECT e.first name, e.last_name, e.job_id, j.min_salary, j.max_salary FROM employees e
NATURAL JOIN jobs USING (job.d);
SELECT efirst name,e last name,ejob_id, j.min_salary. j.max_salary FROM employees ee
NATURAL JOIN jobs
D. SELECT first name, last name, job_id, min_salary, max_salary FROM employees NATURAL JOIN
jobs,

.The join the ANSI-standard syntax used to generate a Cartesian product.

Select one

A. CROSS
B. ALL
C. NATURAL
D. FULL

5. In the relational model, relationships between relations or tables are created by using.

Select one:

A. candidate keys
B. composite keys
C. determinants
D. foreign keys (Right answer:)

6. What is another name for a simple join or an inner join?

Selecttone

A. Outer Join
B. Self Join
Equijoin
D. Nonequijoin

7. Which of the following operators is/are typically used in a nonequijoin?

Select one:

A. OR
3. NOT
C. IN
D.

8. Which syntax would be used to retrieve all rows in both the EMPLOYEES and DEPARTMENTS tables,
even when there is no match?

Select one:

Outer join
B. Inner join
C. Natural join
D. Selfjoin

9. If table A has 10 rows and table B has 5 rows, how many rows will be returned if you perform a
Cartesian join on the table

Select one

10
A
B. 5
C. 15

D. 50

10. The_ statement can be used to combine rows from two queries, returning only the rows that
appear in both sets

Select one:

A INTERSECT
B. UNION
C. UNION ALL
D. UNION Intersect

11. To perform a valid outer join between DEPARTMENTS and EMPLOYEES to list departments without
employees, select the correct clause for the following select statement.

SELECT d.department name, e.last name FROM employees e, departments d WHERE

Select one

A e.department_id(+) = d.department_id(+)

Be.department id(+) =d.department id


Ce.department_id = d.department_id(+)
D e.department_id = d.department_id

12 A union query is which of the following

A. Combines the output from multiple queries and as one including the same number of columns
B. Combines the output from no more than two queries and does not include the same number of
column
C. Combines the output from no more than two queries and must include the same number of
column
D. Combined outputfrom multiple queries and mustincludethe same number of columns
13. Assume you are the intersect operator open to combine the result from 2 table with identical
structure customer and customer_2The customer table contends 10 rows While the customer 2 table
contents 7 row None ofthe customer appearinboth thecustomertable as wellas in customer_2 table
how many records are returned when using intersect operator?

A. 7

B. 17

C. None
D. 10

14 what happene when you create cartesian product?

Select one

AAllrowsfrom one table are joinedtoall rows ofanothertable


BAll rows that do not match in the WHERE claune are displaye

CNo rows are returned as you entered wrong join-criteria

DThe table is joined to itself, one column to the next column, exhausting all possibilities.

15 which two are true about aggregate function?

Select one or more:

A. Youcan use aggregate functions in any clause ofa SELECTstatement


can mixsingle rowcolumns with aggregatefunctions inthe columnlist of aSELECT statement
bygroupingonthe singles row and columnsS
C. You can use aggregate functions only in the column list of the SELECT clause and in the WHERE
clauseof aSELECT statement
Youcan pass column names, expressions,constants, orfunctions as parameterstoan aggregate
function
16. When do we use full outer join?

Select one

A. tables have NULL values


B. want all unmatched data from one table
C. You want all matched data from both tables
D. want all unmatched data from both tables

17Which statement about joining tables with a non-equijoin is false?

Select one

A. The columns being joined must have compatible data types


B. The number of join Condition
A WHERE clause must specify a column in one table that is compared To a column in second
Table,
.

18. SELECT C.customer_id, o.order_id, o.order_date, P.product_name FROM customer c, curr_order o,


product p Where curr_order.customer_id AND o.product _id = p.product_id ORDER BY 0.order_amount

This statement fails when executed. Which change will correct the problem?

Select one:

A. the ORDER AMOUNT columnin the SELECTlist


B. Usethe tablealiasesinstead ofthe table namesin the WHERE clause
C. Remove the table aliases from the WHERE clause
D. Use the table name in the ORDER BY clause

19. Select test statements display 2000 in the format of "$2,000.00"

Select one more

A. SELECT TO CHAR (2000, SN,NNN NN) FROM dual;


B. TO CHAR(2000, S#,###) FROM dual
SELECT TO CHAR (2000, $0,000.00) FROM
dual
D. SELECT TOCHAR (2000,$9,999,00)FROM dual
20. SELECT (10/3)*3 FROM DUAL

Select one

A. 10
B. 10.0
C. 9.99999999
D. 9.99999999999999999999999999999999999999

21. We refer to a join as a self-join when

Select one
A. We are joining top and bottom rows
B. we are joiningtable toitself
C.we are using left and right join together
D. we are joining more than two tables

22. The INNER JOIN Clause.

Select one:

A. returns all rows that have matching value inthe field on which the 2 tables are joined
B. returns only the rows from the first table, which have non-matching values with the second
table in the fig joined
C. returns all rows from 2 tables
D. no rows are returned

23. Which type of join is the following SQL?

SELECT CUSTOMER_T CUSTOMER ID, ORDER_T. CUSTOMER_ID, NAME, ORDER_ID FROM


CUSTOMER_TWHERE CUSTOMER_T CUSTOMER_ID = ORDER_T. CUSTOMER ID

Select one:

A. Equi-join
B. Natural join
C. Outer join
D. Cartesian join

*24. Which operator is not appropriate in the join condition of a non-equi join SELECT statement?

Select one:

A. Greater than or equal to operator


B. LIKE operator
C. IN operator
D. Equal operator
25. A NATURAL JOIN is based on

Select one:

A. columns with the same datatype and width


8. tables with thesame structure
columnswith the same name and datatype
D. tables with the same name

26. The ID column in the CLIENT table that corresponds to the CLIENT_ID column of the ORDER table
contains null be displayed. Which type of join should you use to display the data?

Select one

A. Selfjoin
B. Nonequi-Join
Outer join
D. Equijoin

27. The. statement can be used to combine rows from two queries, returning only the rows that
appears in both sets

Select one:

A. INTERSECT
B. UNION
C. UNION ALL
D. UNION Intersect

28. To produce a meaningful result set without any Cartesian product what is the minimum number of
conditions that should Where clause of a four-table join?

Select one

B.4
C. 2
D. 8

*29. You need to calculate the total of all salaries in the accounting department Which group function
should you use?

Select one:

A. CoUNT
SUM
C. MAX
. MIN

30. A new standard has been adopted in your department that all codes that contain only 3 characters
must have a dash (-} values appended to them. Which function can be used in your query to restrict the
data displayed to only those codes 3 characters?

Select one:

. SUEBSTR
B. LENGTH
C. RPAD
D. REPLACE

31. Which two statements correctly describe functions that are available in SOL?

Select one or more:

A. NVL2 returns the first non-null expression in the expression list


B. TRUNCATE rounds the column, expression, or value to n decimal places
C DECODE translates an expression after comparing it to each search value
D. A.INSTR returns the numeric position of a named character
32. Which of the following statements gets the total value of the column 'Price in the 'Sales' table?

Select one

A. SELECT ADD(Price) FROM Sales


SELECT SUM(Price) FROM Sales
C. SELECT TOTAL (Price) FROM Sales
D. SELECT SUM(Price) WHERE Sales

33. Which of the following sQL statements is correct?

Select one:

A SELECT CustomerName, cOUNT(CustomerName)FROM Orders GROUPBY CustomerName


B. SELECT CustomerName, CALACULATE (CustomerName) FROM Orders
C. SELECT CustomerName, CoUNT(CustomerName) FROM Orders ORDER BY CustomerName
D. SELECT CustomerName, COUNT(CustomerName) FROM Orders

34. You are sorting data in a table in SELECT statement in descending order. The column you are sorting
on contains NULL, records, where will the NULL record appear?

Select one:

A. At the end of the list.


8. Atthesame location they are listed in the unordered table.
C. Atthe beginning of thelist
D. In the middle of the list.

35. You would like to display the system date in the format "Monday, 01 June, 2001 Which SELECT
statement should you use?

Selecttone:

A. SELECT TO CHAR(SYSDATE,'FMDay, DD Month, YYYY) FROM dual


B. SELECT TO_DATE(SYSDATE, FMDAY, DD Month, YYYY) FROM;
C. SELECT TO_CHAR(SYSDATE, FM DY, DDD Month, YYYY)
D. SELECT TO_CHAR(SYSDATE, FMDD, DY Month, YYY) FROM dual;

36 Which function returns the date of given weekday that is greater than the given date?

Select one:
A. TO_DATE
B. LAST DAY
NEXT DAY
D. SYSDATE

37. SELECT ROUND(15 12,-1) FROM DUAL


Select onee

20
B. 15
C. 15.10
D. 16

38. Evaluate the SQL statement:

SELECT ROUND{45.953, -1), TRUNC(45.936, 2) FROM dual; Which values are displayed?

Select one

A. 46 and 45
B. 50 and 45.93
C. 46 and 45.93
D. 50 and 45.9

39. SELECT SIGN( abs(-15) 5) FROM DUAL

Select one:

A. 15

C. -75
D. 75

40. You are using the single row function in a SELECT statement. Which function can best be categorized
as similar in function to an IF-THEN-ELSE statemernt?

Select one

A. DECODE
B. ROWIDTOCHAR.
C. NEW TIME
D. SORT

41. Which of the following is a SQL aggregate function?

Select one:

A LEFT
3. CAST

C
MIN
. RIGHT

42. Select HELLO || NULL|| WORLD FROM QUAL


select hello"|null|Tworld" from dual;
Select one

A. NULL
B. HELLO

C. WORLD
D. HELLOwORLD

select
"hello | | null |l world' from dual;|

Resuts Explain Describe Saved SQL History

helloworld

I raws returned in 0.00 seconds Download

43. Examine the description of the STUDENTS table

STD ID NUMBER(4)

cOURSE ID VARCHARD2(10)

START DATE DATE

END DATE DATE

Which two aggregate functions are valid on the START DATE column? (Choose two options)

Select one or more

A. AVG(start date, end date)


B. DMIN(start date)
C. COUNT(start date
D. SUM(start_date)

It is possible to apply COUNT) and MIN) functions on the column with DATE data type.

45. Which two are character manipulation functions? (Choose two options)

Select one or more.

A. TRUNC
B. REPLACE
C. TO DATE
D. TRIM
46. You want to display the expiration date of the warranty for a product. Which SQL statement would
you execute?

Select one

A. SELECT product_id,SYSDATE +warranty_period FROM productinformation


SELECT product id,TO YMINTERVALISYSDATE+Warrantyperiod) FROM productinformation
C. SELECT product_id, TO YMINTERVAL{warranty period) FROM product information;
D. SELECT product id, TO YMINTERVAL (SYSDATE) + warranty period FROM product information

/here warranty period is not date but number of months (i.e. number)

Q3. View the Exhibit and examine the structure of the


PRODUCT_INFORMATION table.
You want to see the product names and the date of expiration of warranty
for all the products, if the product is purchased today. The products that
have no warranty should be displayed at the top and the products with
maximum warranty period should be displayed at the bottom.
Which SQL statement would you execute to fulfil this requirement?

A SELECT product_name, category id, $YSDATE+warranty period AS


"Warranty expire date" FROM product_information ORDER BY SYSDATE
Warrantypenod
BSELECT product name category id, SYSDATE*warranty period AS
Warranty expire date" FROM product_infomation ORDER BY
SYSDATE+warranty_period,
C. SELECT product name category id, SYSDATE+warranty period AS
Warranty expire date" FROM productinformation ORDER BY SYSDATE;
D. SELECT product_name, category_id, SYSDATE+warranty_period
"Warranty expire date" FROM product_information WHERE
warranty_period >SYSDATE,
View Answer

Answer: B

47. Which two statements are true regarding the ORDER BY clause? (Choose two options)

Select one or more:

A. The ORDER BY clause is executed on the client side


B. Thesortisin descending order by default
C. The ORDER BY clause comes last in the SELECT statement
D. Thesortisin ascending orderby default
48. The ITEM table contains these columns

ITEM ID NUMBER(9)

cOST NUMBER(7,2)

RETAIL NUMBER(7,2)

The RETAIL and COST columns contain values greater than zero

Evaluate these two sQL statements:

1. SELECT item id. (retail 1.25)+ 5.00- (cost 1.10)- (cost .10) AS Calculated Profit FROM item;
2. SELECT item_id, retall 1.25 +5.00-cost 1.10-cost . 10 "Calculated "FROM item;
What will be the result?

Select one

One of the statements will not execute.


B. Statement 1will display the Calculated Profitcolumn heading
C. Statement 1 and statement 2 will return the same value.
D. Statement 1 will return a higher value than statement 2.

49. The following SQL statement was written to retrieve the rows for the PRODUCT ID that has a UNT
PRICE more than 1,000 and has been ordered more than five times:

SELECT product id, COUNT(order id) total, unit price

FROM order items

WHERE unit price> 1000 AND COUNT(order id)>5

GROUP BY product id, unit price.

Which statement is true regarding this SQL statement?

Select one:

A. The statement would not execute because the aggregate function is used in the WHERE clause.
B. The statement would not execute because the WHERE clause should have the OR logical
operator instead of AND.
C. The statement would not execute because in the SELECT Clause, the UNIT PRICE column is
placed after the column having the aggregate function.
D. The statement would execute and give you the desired result

50. Evaluate these two SQL statements:


SELECT last name, salary, hire date FROM EMPLOYEES ORDER BY Salary DESC;

SELECT last name, salary, hire date FROM EMPLOYEES ORDER BY 2 DESC;

What is true about them?

Select one:

A. There is no need to specify DESC because the results are sorted in descending order by default
B. Thetwo statements produceidenticalresults
C. The second statement returns a syntax error
D. The two statements can be made to produce identical results by adding a column alias for the
salary the second SQL statement

51. Given below is a list of functions and their purpose in random order.

Function Purpose

1NVL a) Used for evaluating NOT NULL and NULL values 2)NULLIF b) Used to return the first non- null
values in a list of expressions

3)COALESCE c) Used to compare two expressions. If both are same, it returns NULL; otherwise, it returns
only the first expression.

4)NVL2 d) Used to convert NULL values to actual values Identify the correct combination of functions In
the usage.

Select one

A. 1-d,2-b,3-c,4-a
B. 1-a,2-c,3-b.4-d
C. 1-b,2-c3-d,4-a
D. 1-d,2-c3-b,4-a
52. Evaluate this SQL statement:

SELECT C.customer_ld, o.order_id, o.order_date, p.product_name FROM customer c, curr_order o,


product p WHERE customer.customer_id = curr_order.customer_id AND 0.product_id = p.product_Id

ORDER BY o order amount. This

statement fails when executed. Which change will correct the problem?

Select one:

A. Use the table nameinthe ORDER BY clause.


B. Usethe table aliasesinstead ofthe table namesin the WHERE clause
C. Include the ORDER AMOUNT column in the SELECT list.
D. Remove the table aliases from the WHERE clause.

53. Which two statements are true regarding single row functions? (Choose two options)

Select one or more:


They can be used in SELECT, WHERE, and ORDER BY clauses
Theycan modify the data type of theargument thatis referenced
C. They can be nested up to only two levels.
D. They can return multiple values of more than one data type.

54. The join column must be included in the select statement when you use the NATURAL JOIN clause,
State True False.

Select one:

A. Irue
3. False
55. You can use combination of GROUP BY clause, HAVING Clause and WHERE clause sQL clauses in one
SQL

statement. State True or False.

Select one

A. True
B. False

S6. SELECT c.country.name, d.department name FROM countries c.departments d WHERE country_id (+)
d.country.id (+)
State True or False.

Select one:

A. True
3. False

57. Find the odd one.

Select one:

A. date number
B. date+date
C. date-date
D. Date+number

Results Explain Describe Saved SQ

RA-O0975: date. 1 date not allowed

You might also like