SQL For Testers
SQL For Testers
SQL For Testers
3. Q. What is a join?
A. Join is a process of retrieve pieces of data from different sets (tables)
and returns them to the user or program as one “joined†collection of data.
cross-join
SELECT * FROM table1, table2;
self join
SELECT e1.name | |’ ‘ | | e2.ename FROM emp e1, emp e2 WHERE e1. emp_no =
e2.emp_no;
12. Q. Can a table have more than one foreign key defined?
A. A table can have any number of foreign keys defined. It can have only
one primary key defined.
13. Q. List all the possible values that can be stored in a BOOLEAN data field.
A. There are only two values that can be stored in a BOOLEAN data field:
-1(true) and 0(false).
14 Q. What is the highest value that can be stored in a BYTE data field?
A. The highest value that can be stored in a BYTE field is 255. or from -128
to 127. Byte is a set of Bits that represent a single character.
Usually there are 8 Bits in a Byte, sometimes more, depending on how
the measurement is being made. Each Char requires one byte of memory
and can have a value from 0 to 255 (or 0 to 11111111 in binary).
15. Q. How many places to the right of the decimal can be stored in a
CURRENCY data field?
A. The CURRENCY data type can store up to four places to the right of the
decimal. Any data beyond the fourth place will be truncated by Visual
Basic without reporting an error.
21. Q. Which of the following WHERE clauses will return only rows
that have a NULL in the PerDiemExpenses column?
A. WHERE PerDiemExpenses <>
B. WHERE PerDiemExpenses IS NULL
C. WHERE PerDiemExpenses = NULL
D. WHERE PerDiemExpenses NOT IN (*)
A. B is correct � When searching for a NULL value in a column, you must
use the keyword IS. No quotes are required around the keyword NULL.
A. C is correct � Two wildcards are used with the LIKE operator.
The underscore (_) stands for any one character of any
case, and the percent sign (%) stands for any number of
characters of any case including none. Because this string
starts with an underscore rather than a percent sign, it won't
return Allen or Clark because they represent zero and two
characters before the "A". If the LIKE string had been "%A%",
both of these values would have been returned.
David was not returned because all non-wild card characters
are case sensitive. Therefore, only strings
with an uppercase "A" as their second letter are returned
23. Q. Write a SQL SELECT query that only returns each city only once from
Students table?
Do you need to order this list with an ORDER BY clause?
<!--
google_ad_client = "pub-7042471392556119";
google_ad_width = 728;
google_ad_height = 15;
google_ad_format = "728x15_0ads_al";
google_ad_channel ="";
google_color_border = "DFF2FD";
google_color_bg = "DFF2FD";
google_color_link = "0000FF";
google_color_url = "008000";
google_color_text = "000000";
//-->
google_protectAndRun("ads_core.google_render_ad", google_handleError,
google_render_ad);
26. Q. Write SQL SELECT example how you limiting the rows returned with a WHERE
clause.
27. Q. Write SQL SELECT query that returns the first and
last name of each instructor, the Salary,
and gives each of them a number.
28. Q. Which of the following functions can be used only with numeric values?
(Choose all that apply.)
A. AVG
B. MIN
C. LENGTH
D. SUM
E. ROUND
31. Q. Is the WHERE clause must appear always before the GROUP BY clause in SQL
SELECT ?
A. Yes.
The proper order for SQL SELECT
clauses is: SELECT, FROM, WHERE, GROUP BY, HAVING, ORDER BY.
Only the SELECT and FROM clause are mandatory.
A. You use the MINUS operator to return all rows from one query except
where duplicate rows are found in a second query. The UNION operator
returns all rows from both queries minus duplicates. The UNION ALL operator
returns all rows from both queries including duplicates.
The INTERSECT operator returns only those rows that exist in both queries.
39. Question. What are the main components of Database management systems
software.
A. The database management system software includes
components for storage management, concurrency control, transaction
processing, database manipulation interface, database definition interface,
and database control interface.
40. Question. What are the main attributes of database management system?
A. A database management system is composed of five elements: computer
hardware, software, data, people (users), and operations procedures.
Answer: j and a aliases for table names. this is outer joint select statament
from two tables.
A. 1) The COUNT function tells you how many rows were in the result set.
SELECT COUNT(*) FROM TESTING.QA
2) The AVG function tells you the average value of a numeric column.
SELECT MAX(SALARY) FROM TESTING.QA
3) The MAX and MIN functions tell you the maximum and minimum value of a
numeric column.
SELECT MIN(SALARY) FROM TESTING.QA
4) The SUM function tells you the sum value of a numeric column.
SELECT SUM(SALARY) FROM TESTING.QA
52. Question:
In the domain table we have status as a numeric value from 01 to 04 and we
have text definition of these values in the design document.
Write SQL query to see the result as a text definitions that is corresponded
to these values. (DB2)
A. select TB1.member_id, TB1.bu_id, TB1.program, TB2.num,
case TB1.status
when '01' then 'Auto renew'
when '02' then 'Expired'
when '03' then 'Sold'
when '04' then ‘Terminated’
else TB_name.status
end
from DB_name.TB_name1 TB1,
DB_name.TB_name2 TB2
where
TB1.program in ('com', 'org')
and TB1.member_role = '100'
order by TB1.member_id
fetch first 30 rows only