Multiple Choice Questions - SQL Where with Wildcards
1.
Persons table:
LastName | FirstName |
---|---|
aaa_L | aaa_F |
bbb_L | bbb_F |
ccc_L | ccc_F |
ddd_L | ddd_F |
eee_L | eee_F |
aaa_L | aaa_F |
xxxL | NULL |
xxxl | NULL |
ML | NULL |
Select * from Persons Where LastName like '_L';What will be the result of above query:
A)
LastName | FirstName |
---|---|
ML | NULL |
B)
LastName | FirstName |
---|---|
aaa_L | aaa_F |
bbb_L | bbb_F |
ccc_L | ccc_F |
ddd_L | ddd_F |
eee_L | eee_F |
aaa_L | aaa_F |
xxxL | NULL |
ML | NULL |
C)
LastName | FirstName |
---|---|
aaa_L | aaa_F |
bbb_L | bbb_F |
ccc_L | ccc_F |
ddd_L | ddd_F |
eee_L | eee_F |
aaa_L | aaa_F |
D) None of above
2.
Persons table:
LastName | FirstName |
---|---|
aaa_L | aaa_F |
bbb_L | bbb_F |
ccc_L | ccc_F |
ddd_L | ddd_F |
eee_L | eee_F |
NULL | aaa_f |
aaa_L | aaa_F |
xxxL | NULL |
xxxl | NULL |
ML | NULL |
What will be the result of the below query:
Select * from Persons Where FirstName like '[_]f';A)
LastName | FirstName |
---|---|
aaa_L | aaa_F |
bbb_L | bbb_F |
ccc_L | ccc_F |
ddd_L | ddd_F |
eee_L | eee_F |
NULL | aaa_f |
aaa_L | aaa_F |
B)
LastName | FirstName |
---|---|
NULL | aaa_f |
C)
LastName | FirstName |
---|---|
aaa_L | aaa_F |
bbb_L | bbb_F |
ccc_L | ccc_F |
ddd_L | ddd_F |
eee_L | eee_F |
NULL | aaa_f |
aaa_L | aaa_F |
xxxL | NULL |
xxxl | NULL |
ML | NULL |
D)
LastName | FirstName |
---|
3.
Persons table:
LastName | FirstName |
---|---|
aaa_L | aaa_F |
bbb_L | bbb_F |
ccc_L | ccc_F |
ddd_L | ddd_F |
eee_L | eee_F |
NULL | aaa_f |
aaa_L | aaa_F |
xxxL | NULL |
xxxl | NULL |
ML | NULL |
What is the result of below query:
Select * from Persons Where LastName like '%_L';A)
LastName | FirstName |
---|---|
aaa_L | aaa_F |
bbb_L | bbb_F |
ccc_L | ccc_F |
ddd_L | ddd_F |
eee_L | eee_F |
aaa_L | aaa_F |
NULL | aaa_f |
xxxL | NULL |
xxxl | NULL |
ML | NULL |
B)
LastName | FirstName |
---|---|
aaa_L | aaa_F |
bbb_L | bbb_F |
ccc_L | ccc_F |
ddd_L | ddd_F |
eee_L | eee_F |
aaa_L | aaa_F |
C)
LastName | FirstName |
---|---|
aaa_L | aaa_F |
bbb_L | bbb_F |
ccc_L | ccc_F |
ddd_L | ddd_F |
eee_L | eee_F |
aaa_L | aaa_F |
xxxL | NULL |
xxxl | NULL |
ML | NULL |
D) None of above
4.
My_date table:
Birthdate |
---|
2015-01-21 |
2015-01-22 |
2015-01-23 |
2015-01-24 |
2015-01-25 |
2015-01-26 |
NULL |
2015-01-19 |
Select * from My_date Where Birthdate like '2015[-]01[.-]%';Tell the result of above query:
A)
Birthdate |
---|
2015-01-21 |
2015-01-22 |
2015-01-23 |
2015-01-24 |
2015-01-25 |
2015-01-26 |
2015-01-19 |
B) NULL
C)
Birthdate |
---|
D)
Birthdate |
---|
2015-01-21 |
2015-01-22 |
2015-01-23 |
2015-01-24 |
2015-01-25 |
2015-01-26 |
NULL |
2015-01-19 |
5.
High_Scorers table:
StudentID | Name | Total_Student_Marks |
---|---|---|
S001 | Kartik | 98 |
S002 | Sunny | 83 |
S003 | Jimmy | 75 |
S004 | Chotu | 71 |
S0012 | Sunil | 99 |
S00 | A Be | 100 |
What will be the result of below query:
Select * from High_Scorers WHERE LEFT(StudentID, 3) IN ('S00')A)
StudentID | Name | Total_Student_Marks |
---|---|---|
S001 | Kartik | 98 |
S002 | Sunny | 83 |
S003 | Jimmy | 75 |
S004 | Chotu | 71 |
S0012 | Sunil | 99 |
S00 | A Be | 100 |
B)
StudentID |
---|
S001 |
S002 |
S003 |
S004 |
S0012 |
S00 |
C)
StudentID | Name | Total_Student_Marks |
---|---|---|
S001 | Kartik | 98 |
S002 | Sunny | 83 |
S003 | Jimmy | 75 |
S004 | Chotu | 71 |
S00 | A Be | 100 |
D) None of above
6.
Consumer table:
Cust_ID | Name | City | IndustryType |
---|---|---|---|
4 | Chocolate | pleasant | J |
6 | Pastry | Oaktown | J |
7 | Samosa | Jackson | B |
9 | Orange | Jackson | B |
What is the result of below query:
Select * from Consumer Where City like '%%Jackson';A)
Cust_ID | Name | City | IndustryType |
---|---|---|---|
7 | Samosa | Jackson | B |
9 | Orange | Jackson | B |
B) It will throw an error.
C)
Cust_ID | Name | City | IndustryType |
---|---|---|---|
4 | Chocolate | pleasant | J |
6 | Pastry | Oaktown | J |
7 | Samosa | Jackson | B |
9 | Orange | Jackson | B |
D)
Cust_ID | City | IndustryType |
---|---|---|
4 | pleasant | J |
6 | Oaktown | J |
7 | Jackson | B |
9 | Jackson | B |
7.
Geography table:
Region_Name | Store_Name |
---|---|
East | Boston |
East | New York |
West | Los Angeles |
West | San Diego |
Select the result of the below query:
Select * from Geography Where store_name LIKE '%' + ' ' + '%';A)
No concatenation is allowed with LIKE, so it will throw an error.
B)
Region_Name | Store_Name |
---|---|
East | Boston |
East | New York |
West | Los Angeles |
West | San Diego |
C)
Store_Name |
---|
Boston |
New York |
Los Angeles |
San Diego |
D)
Region_Name | Store_Name |
---|---|
East | New York |
West | Los Angeles |
West | San Diego |
8.
C table:
FirstName |
---|
abcde |
abcdefg |
abcef |
abcdefgh |
bcdef |
cdef |
[abcdef] |
Select * from C Where firstname LIKE '[abc[def][e][f]%';Result of the above query will be:
A)
FirstName |
---|
B)
FirstName |
---|
abcde |
abcdefg |
abcef |
abcdefgh |
bcdef |
cdef |
[abcdef] |
C)
FirstName |
---|
[abcdef] |
D) None of above
9.
C table:
FirstName |
---|
abcde |
abcdefg |
abcef |
abcdefgh |
bcdef |
cdef |
[abcdef] |
Choose the result of the below query:
Select * from C Where firstname LIKE '[[]a%]';A)
FirstName |
---|
abcdefgh |
[abcdef] |
B)
FirstName |
---|
abcde |
abcdefg |
abcef |
abcdefgh |
bcdef |
cdef |
[abcdef] |
C)
FirstName |
---|
[abcdef] |
D) It will throw an error
10.
C table:
FirstName |
---|
abcde |
abcdefg |
abcef |
abcdefgh |
bcdef |
cdef |
[abcdef] |
[ab\cdef] |
[ab\ |
Result required is:
FirstName |
---|
[ab\ |
Which of the queries will find the above result:
A)
Select * from C Where FirstName like '[ab_';B)
Select * from C Where FirstName like '%ab_';C)
Select * from C Where FirstName like '[[]ab_';D)
Select * from C Where FirstName like '[ab\' ESCAPE'[';
Answers