SlideShare una empresa de Scribd logo
1 de 29
Descargar para leer sin conexión
Top 20 sql queries interview questions 
and answers 
If you need top 7 free ebooks below for your job interview, please visit: 
4career.net 
• Free ebook: 75 interview questions and answers 
• Top 12 secrets to win every job interviews 
• 13 types of interview quesitons and how to face them 
• Top 8 interview thank you letter samples 
• Top 7 cover letter samples 
• Top 8 resume samples 
• Top 15 ways to search new jobs 
Interview questions and answers – free pdf download Page 1 of 29
Tell me about yourself? 
This is probably the most asked 
question in sql queries interview. It 
breaks the ice and gets you to talk 
about something you should be fairly 
comfortable with. Have something 
prepared that doesn't sound rehearsed. 
It's not about you telling your life story 
and quite frankly, the interviewer just 
isn't interested. Unless asked to do so, 
stick to your education, career and 
current situation. Work through it 
chronologically from the furthest back 
to the present. 
Interview questions and answers – free pdf download Page 2 of 29
What is the difference between “delete” , 
“truncate” and “drop” commands 
Delete Command : Delete Command 
Belongs to DML 
Can be Used to delete entire Table data 
Can be used to delete specific rows using 
where clause 
Can be rolled back 
Truncate Command: Truncate Command 
Belongs to DDL 
Can be Used to delete entire Table data 
Can't be used to delete specific rows using 
where clause 
Can't be rolled back 
Drop Command: Drop Command Belongs 
to DDL 
Can be Used to delete entire Table data and 
also the structure Can't be used to delete 
specific rows using where clause 
Can't be rolled back 
Interview questions and answers – free pdf download Page 3 of 29
What Can You Do for Us That Other Candidates 
Can't? 
What makes you unique? This 
will take an assessment of 
your experiences, skills and 
traits. Summarize concisely: 
"I have a unique combination 
of strong technical skills, and 
the ability to build strong 
customer relationships. This 
allows me to use my 
knowledge and break down 
information to be more user-friendly." 
Interview questions and answers – free pdf download Page 4 of 29
What is the difference between primary key and 
unique key 
Unique Key: 
a.A table can contain more than one 
unique key 
b.Unique key allows one null value 
Primary Key: 
a.A table can contain only one primary 
key (can be one/more columns) 
b.Primary key will not allow null values 
Interview questions and answers – free pdf download Page 5 of 29
What is the difference between sub queries and 
joins 
a.Sub Queries : 
To write sub queries between two or 
more tables, there is no need to be 
relation exist among those tables 
b.Joins: 
To write joins between two or more 
tables, there should be relation exist 
among those tables 
Interview questions and answers – free pdf download Page 6 of 29
Write syntax for views and stored procedures 
View Syntax: 
Create view <view-name> as select 
<column names> from <table-name> 
where <condition> 
Stored Procedure Sysntax: 
Create procedure <procedure-name> 
as begin select <column names> from 
<table-name> end 
Note: These are only sample 
examples, we can write in different 
ways also. 
Interview questions and answers – free pdf download Page 7 of 29
What are the different constraints available in 
sql and Explain 
Not Null -> enforces a column to 
Not accept Null values 
Unique -> uniquely identifies each 
record in a database table 
Primary Key -> uniquely identifies 
each record in a database table and it 
cannot contain NULL values. 
Foreign Key -> A Foreign Key in one 
table points to a PRIMARY KEY in 
another table. 
Check -> It is used to limit the 
value range that can be placed in a 
column. 
Default -> It is used to insert a 
default value into a column. 
Interview questions and answers – free pdf download Page 8 of 29
By default how the column data would display if 
use order by <column> 
By default the order by would display 
the data in ascending order 
Syntax: 
a. select <col-names> from <table-name> 
order by <col-names> 
It will display the results in ascending 
order 
select <col-names> from <table-name> 
order by <col-names> desc 
It will display the results in descending 
order 
select <col-names> from <table-name> 
order by <col-names> asc 
It will display the results in ascending 
order 
Interview questions and answers – free pdf download Page 9 of 29
What is the operator in sql to find pattern match 
Like 
Select <colnames> from <table-name> 
where <col> like <pattern> 
Ex: 
a. 
Select ename from emp where ename 
like ‘v%’ 
It will display all the names which are 
start with ‘v’ 
b. 
Select ename from emp where ename 
not like ‘v%’ 
It will display other than all the names 
which are start with ‘v’ 
Interview questions and answers – free pdf download Page 10 of 29
What is the purpose of ‘distinct’ in sql 
Distinct is used to display only the 
different values 
Ex: 
Select distinct <col-names> from 
<table-name> 
Select distinct ename from emp 
Interview questions and answers – free pdf download Page 11 of 29
What is the difference between union and union 
all 
The UNION operator selects only distinct 
values by default. To allow duplicate 
values, use UNION ALL 
Select <col-names> from <table1> union 
select <col-names> from <table2> 
Select <col-names> from <table1> union 
all select <col-names> from <table2> 
Interview questions and answers – free pdf download Page 12 of 29
How can I find total number of employees with 
more than 40 years? 
SELECT 
COUNT(EMPLOYEES.*) FROM 
EMPLOYEES 
WHERE EMPLOYEES.Age>40 
Interview questions and answers – free pdf download Page 13 of 29
How to create Identity Column using Query? 
SELECT 
row_number() OVER(ORDER by 
TESTTABLE.p1) as SRNO, 
result=CASE 
WHEN TESTTABLE.p1 IS NOT 
NULL THEN TESTTABLE.p1 
WHEN TESTTABLE.p2 IS NOT 
NULL THEN TESTTABLE.p2 
END 
FROM TESTTABLE 
Interview questions and answers – free pdf download Page 14 of 29
How do I select 2nd highest salaried employee 
from my EMPLOYEE table? 
SELECT 
EMPLOYEE.*, 
MAX(EMPLOYEE.Salary) AS 
SalarySecondHighest 
FROM EMPLOYEE 
WHERE EMPLOYEE.Salary< 
(SELECT 
MAX(EMPLOYEE.Salary) AS 
SalaryFirstHighest 
FROM EMPLOYEE) 
Interview questions and answers – free pdf download Page 15 of 29
How to select top 3 employees from EMPLOYEE 
table which is grouped in the salary groups? 
SELECT 
EMPLOYEE.* 
FROM 
(SELECT EMPLOYEE.*, 
rank() OVER(PARTITION BY 
EMPLOYEE.Salary ORDER BY 
EMPLOYEE.Salary ASC) AS Rank 
from EMPLOYEE 
) EMPLOYEE 
where Rank<3 
-- if you want to top n employees for each 
grouped salary 
-- replace 3 in the query with (n+1) 
ORDER BY EMPLOYEE.Salary 
Interview questions and answers – free pdf download Page 16 of 29
How to find all the employees from EMPLOYEE 
table who earns more than the average salary of 
their department 
SELECT 
OUTEREMPLOYEE.*, 
OUTEREMPLOYEE.Salary 
FROM 
EMPLOYEE OUTEREMPLOYEE 
WHERE OUTEREMPLOYEE.Salary > 
(SELECT 
AVG(INNEREMPLOYEE.Salary) 
FROM 
EMPLOYEE INNEREMPLOYEE 
WHERE 
OUTEREMPLOYEE.DepartmentID = 
INNEREMPLOYEE.DepartmentID) 
Interview questions and answers – free pdf download Page 17 of 29
How to list employees with period of service in 
terms of years and months? 
SELECT 
EMPLOYEE.*,TO_CHAR(TRUNC( 
MONTHS_BETWEEN(SYSDATE, 
EMPLOYEE.HireDate)/12)) 
AS 
Years, TO_CHAR(TRUNC( MOD(MO 
NTHS_BETWEEN(SYSDATE, 
EMPLOYEE.HireDate),12))) AS Months 
FROM EMPLOYEE 
Interview questions and answers – free pdf download Page 18 of 29
How to display only Even Records from 
EMPLOYEE table? 
SELECT 
EMPLOYEE.* 
FROM EMPLOYEE 
WHERE (rowid,0) in 
(SELECT rowid,mod(rownum,2) 
FROM EMPLOYEE) 
Interview questions and answers – free pdf download Page 19 of 29
How to display only Odd Records from 
EMPLOYEE table? 
SELECT 
EMPLOYEE.* 
FROM EMPLOYEE 
WHERE (rowid,1) in 
(SELECT rowid,mod(rownum,2) 
FROM EMPLOYEE) 
Interview questions and answers – free pdf download Page 20 of 29
What are DDL and DML commands? 
DDL (DataDifinition Language): 
Create 
Alter 
Truncate 
Drop 
DML (Data Manipulation 
Language): 
Select 
Insert 
Update 
Deletet 
Interview questions and answers – free pdf download Page 21 of 29
Useful job interview materials: 
If you need top free ebooks below for your job interview, please visit: 
4career.net 
• Free ebook: 75 interview questions and answers 
• Top 12 secrets to win every job interviews 
• Top 36 situational interview questions 
• 440 behavioral interview questions 
• 95 management interview questions and answers 
• 30 phone interview questions 
• Top 8 interview thank you letter samples 
• 290 competency based interview questions 
• 45 internship interview questions 
• Top 7 cover letter samples 
• Top 8 resume samples 
• Top 15 ways to search new jobs 
Interview questions and answers – free pdf download Page 22 of 29
Top 6 tips for job interview 
Interview questions and answers – free pdf download Page 23 of 29
Tip 1: Do your homework 
You'll likely be asked difficult questions 
during the interview. Preparing the list of 
likely questions in advance will help you 
easily transition from question to question. 
Spend time researching the company. Look 
at its site to understand its mission statement, 
product offerings, and management team. A 
few hours spent researching before your 
interview can impress the hiring manager 
greatly. Read the company's annual report 
(often posted on the site), review the 
employee's LinkedIn profiles, and search the 
company on Google News, to see if they've 
been mentioned in the media lately. The 
more you know about a company, the more 
you'll know how you'll fit in to it. 
Ref material: 4career.net/job-interview-checklist- 
40-points 
Interview questions and answers – free pdf download Page 24 of 29
Tip 2: First impressions 
When meeting someone for the first time, we 
instantaneously make our minds about various aspects of 
their personality. 
Prepare and plan that first impression long before you 
walk in the door. Continue that excellent impression in 
the days following, and that job could be yours. 
Therefore: 
· Never arrive late. 
· Use positive body language and turn on your 
charm right from the start. 
· Switch off your mobile before you step into the 
room. 
· Look fabulous; dress sharp and make sure you look 
your best. 
· Start the interview with a handshake; give a nice 
firm press and then some up and down movement. 
· Determine to establish a rapport with the 
interviewer right from the start. 
· Always let the interviewer finish speaking before 
giving your response. 
· Express yourself fluently with clarity and 
precision. 
Useful material: 4career.net/top-10-elements-to-make-a- 
Interview questions and answers – free pdf download Page 25 of 29
good-first-impression-at-a-job-interview 
Tip 3: The “Hidden” Job Market 
Many of us don’t recognize that hidden job 
market is a huge one and accounts for 2/3 
of total job demand from enterprises. This 
means that if you know how to exploit a 
hidden job market, you can increase your 
chance of getting the job up to 300%. 
In this section, the author shares his 
experience and useful tips to exploit hidden 
job market. 
Here are some sources to get penetrating 
into a hidden job market: Friends; Family; 
Ex-coworkers; Referral; HR communities; 
Field communities; Social networks such 
as Facebook, Twitter…; Last recruitment 
ads from recruiters; HR emails of potential 
recruiters… 
Interview questions and answers – free pdf download Page 26 of 29
Tip 4: Do-It-Yourself Interviewing Practice 
There are a number of ways to prepare 
for an interview at home without the 
help of a professional career counselor 
or coach or a fee-based service. 
You can practice interviews all by 
yourself or recruit friends and family to 
assist you. 
Useful material: 4career.net/free-ebook- 
75-interview-questions-and-answers 
Interview questions and answers – free pdf download Page 27 of 29
Tip 5: Ask questions 
Do not leave the interview without 
ensuring that you know all that you 
want to know about the position. Once 
the interview is over, your chance to 
have important questions answered has 
ended. Asking questions also can show 
that you are interested in the job. Be 
specific with your questions. Ask about 
the company and the industry. Avoid 
asking personal questions of the 
interviewer and avoid asking questions 
pertaining to politics, religion and the 
like. 
Ref material: 4career.net/25-questions-to- 
ask-employers-during-your-job-interview 
Interview questions and answers – free pdf download Page 28 of 29
Tip 6: Follow up and send a thank-you note 
Following up after an interview can 
help you make a lasting impression and 
set you apart from the crowd. 
Philip Farina, CPP, a security career 
expert at Manta Security Management 
Recruiters, says: "Send both an email as 
well as a hard-copy thank-you note, 
expressing excitement, qualifications 
and further interest in the position. 
Invite the hiring manager to contact you 
for additional information. This is also 
an excellent time to send a strategic 
follow-up letter of interest." 
Ref material: 4career.net/top-8- 
interview-thank-you-letter-samples 
Interview questions and answers – free pdf download Page 29 of 29

Más contenido relacionado

Último

Grade Three -ELLNA-REVIEWER-ENGLISH.pptx
Grade Three -ELLNA-REVIEWER-ENGLISH.pptxGrade Three -ELLNA-REVIEWER-ENGLISH.pptx
Grade Three -ELLNA-REVIEWER-ENGLISH.pptxkarenfajardo43
 
DiskStorage_BasicFileStructuresandHashing.pdf
DiskStorage_BasicFileStructuresandHashing.pdfDiskStorage_BasicFileStructuresandHashing.pdf
DiskStorage_BasicFileStructuresandHashing.pdfChristalin Nelson
 
6 ways Samsung’s Interactive Display powered by Android changes the classroom
6 ways Samsung’s Interactive Display powered by Android changes the classroom6 ways Samsung’s Interactive Display powered by Android changes the classroom
6 ways Samsung’s Interactive Display powered by Android changes the classroomSamsung Business USA
 
CLASSIFICATION OF ANTI - CANCER DRUGS.pptx
CLASSIFICATION OF ANTI - CANCER DRUGS.pptxCLASSIFICATION OF ANTI - CANCER DRUGS.pptx
CLASSIFICATION OF ANTI - CANCER DRUGS.pptxAnupam32727
 
Q-Factor General Quiz-7th April 2024, Quiz Club NITW
Q-Factor General Quiz-7th April 2024, Quiz Club NITWQ-Factor General Quiz-7th April 2024, Quiz Club NITW
Q-Factor General Quiz-7th April 2024, Quiz Club NITWQuiz Club NITW
 
How to Manage Buy 3 Get 1 Free in Odoo 17
How to Manage Buy 3 Get 1 Free in Odoo 17How to Manage Buy 3 Get 1 Free in Odoo 17
How to Manage Buy 3 Get 1 Free in Odoo 17Celine George
 
Employablity presentation and Future Career Plan.pptx
Employablity presentation and Future Career Plan.pptxEmployablity presentation and Future Career Plan.pptx
Employablity presentation and Future Career Plan.pptxryandux83rd
 
4.9.24 Social Capital and Social Exclusion.pptx
4.9.24 Social Capital and Social Exclusion.pptx4.9.24 Social Capital and Social Exclusion.pptx
4.9.24 Social Capital and Social Exclusion.pptxmary850239
 
ICS 2208 Lecture Slide Notes for Topic 6
ICS 2208 Lecture Slide Notes for Topic 6ICS 2208 Lecture Slide Notes for Topic 6
ICS 2208 Lecture Slide Notes for Topic 6Vanessa Camilleri
 
An Overview of the Calendar App in Odoo 17 ERP
An Overview of the Calendar App in Odoo 17 ERPAn Overview of the Calendar App in Odoo 17 ERP
An Overview of the Calendar App in Odoo 17 ERPCeline George
 
The role of Geography in climate education: science and active citizenship
The role of Geography in climate education: science and active citizenshipThe role of Geography in climate education: science and active citizenship
The role of Geography in climate education: science and active citizenshipKarl Donert
 
31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...
31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...
31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...Nguyen Thanh Tu Collection
 
Comparative Literature in India by Amiya dev.pptx
Comparative Literature in India by Amiya dev.pptxComparative Literature in India by Amiya dev.pptx
Comparative Literature in India by Amiya dev.pptxAvaniJani1
 
ClimART Action | eTwinning Project
ClimART Action    |    eTwinning ProjectClimART Action    |    eTwinning Project
ClimART Action | eTwinning Projectjordimapav
 
Shark introduction Morphology and its behaviour characteristics
Shark introduction Morphology and its behaviour characteristicsShark introduction Morphology and its behaviour characteristics
Shark introduction Morphology and its behaviour characteristicsArubSultan
 
DBMSArchitecture_QueryProcessingandOptimization.pdf
DBMSArchitecture_QueryProcessingandOptimization.pdfDBMSArchitecture_QueryProcessingandOptimization.pdf
DBMSArchitecture_QueryProcessingandOptimization.pdfChristalin Nelson
 

Último (20)

Grade Three -ELLNA-REVIEWER-ENGLISH.pptx
Grade Three -ELLNA-REVIEWER-ENGLISH.pptxGrade Three -ELLNA-REVIEWER-ENGLISH.pptx
Grade Three -ELLNA-REVIEWER-ENGLISH.pptx
 
DiskStorage_BasicFileStructuresandHashing.pdf
DiskStorage_BasicFileStructuresandHashing.pdfDiskStorage_BasicFileStructuresandHashing.pdf
DiskStorage_BasicFileStructuresandHashing.pdf
 
6 ways Samsung’s Interactive Display powered by Android changes the classroom
6 ways Samsung’s Interactive Display powered by Android changes the classroom6 ways Samsung’s Interactive Display powered by Android changes the classroom
6 ways Samsung’s Interactive Display powered by Android changes the classroom
 
CLASSIFICATION OF ANTI - CANCER DRUGS.pptx
CLASSIFICATION OF ANTI - CANCER DRUGS.pptxCLASSIFICATION OF ANTI - CANCER DRUGS.pptx
CLASSIFICATION OF ANTI - CANCER DRUGS.pptx
 
CARNAVAL COM MAGIA E EUFORIA _
CARNAVAL COM MAGIA E EUFORIA            _CARNAVAL COM MAGIA E EUFORIA            _
CARNAVAL COM MAGIA E EUFORIA _
 
Q-Factor General Quiz-7th April 2024, Quiz Club NITW
Q-Factor General Quiz-7th April 2024, Quiz Club NITWQ-Factor General Quiz-7th April 2024, Quiz Club NITW
Q-Factor General Quiz-7th April 2024, Quiz Club NITW
 
Paradigm shift in nursing research by RS MEHTA
Paradigm shift in nursing research by RS MEHTAParadigm shift in nursing research by RS MEHTA
Paradigm shift in nursing research by RS MEHTA
 
How to Manage Buy 3 Get 1 Free in Odoo 17
How to Manage Buy 3 Get 1 Free in Odoo 17How to Manage Buy 3 Get 1 Free in Odoo 17
How to Manage Buy 3 Get 1 Free in Odoo 17
 
Employablity presentation and Future Career Plan.pptx
Employablity presentation and Future Career Plan.pptxEmployablity presentation and Future Career Plan.pptx
Employablity presentation and Future Career Plan.pptx
 
4.9.24 Social Capital and Social Exclusion.pptx
4.9.24 Social Capital and Social Exclusion.pptx4.9.24 Social Capital and Social Exclusion.pptx
4.9.24 Social Capital and Social Exclusion.pptx
 
ICS 2208 Lecture Slide Notes for Topic 6
ICS 2208 Lecture Slide Notes for Topic 6ICS 2208 Lecture Slide Notes for Topic 6
ICS 2208 Lecture Slide Notes for Topic 6
 
An Overview of the Calendar App in Odoo 17 ERP
An Overview of the Calendar App in Odoo 17 ERPAn Overview of the Calendar App in Odoo 17 ERP
An Overview of the Calendar App in Odoo 17 ERP
 
The role of Geography in climate education: science and active citizenship
The role of Geography in climate education: science and active citizenshipThe role of Geography in climate education: science and active citizenship
The role of Geography in climate education: science and active citizenship
 
31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...
31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...
31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...
 
Comparative Literature in India by Amiya dev.pptx
Comparative Literature in India by Amiya dev.pptxComparative Literature in India by Amiya dev.pptx
Comparative Literature in India by Amiya dev.pptx
 
Spearman's correlation,Formula,Advantages,
Spearman's correlation,Formula,Advantages,Spearman's correlation,Formula,Advantages,
Spearman's correlation,Formula,Advantages,
 
prashanth updated resume 2024 for Teaching Profession
prashanth updated resume 2024 for Teaching Professionprashanth updated resume 2024 for Teaching Profession
prashanth updated resume 2024 for Teaching Profession
 
ClimART Action | eTwinning Project
ClimART Action    |    eTwinning ProjectClimART Action    |    eTwinning Project
ClimART Action | eTwinning Project
 
Shark introduction Morphology and its behaviour characteristics
Shark introduction Morphology and its behaviour characteristicsShark introduction Morphology and its behaviour characteristics
Shark introduction Morphology and its behaviour characteristics
 
DBMSArchitecture_QueryProcessingandOptimization.pdf
DBMSArchitecture_QueryProcessingandOptimization.pdfDBMSArchitecture_QueryProcessingandOptimization.pdf
DBMSArchitecture_QueryProcessingandOptimization.pdf
 

Top sql queries interview questions and answers job interview tips

  • 1. Top 20 sql queries interview questions and answers If you need top 7 free ebooks below for your job interview, please visit: 4career.net • Free ebook: 75 interview questions and answers • Top 12 secrets to win every job interviews • 13 types of interview quesitons and how to face them • Top 8 interview thank you letter samples • Top 7 cover letter samples • Top 8 resume samples • Top 15 ways to search new jobs Interview questions and answers – free pdf download Page 1 of 29
  • 2. Tell me about yourself? This is probably the most asked question in sql queries interview. It breaks the ice and gets you to talk about something you should be fairly comfortable with. Have something prepared that doesn't sound rehearsed. It's not about you telling your life story and quite frankly, the interviewer just isn't interested. Unless asked to do so, stick to your education, career and current situation. Work through it chronologically from the furthest back to the present. Interview questions and answers – free pdf download Page 2 of 29
  • 3. What is the difference between “delete” , “truncate” and “drop” commands Delete Command : Delete Command Belongs to DML Can be Used to delete entire Table data Can be used to delete specific rows using where clause Can be rolled back Truncate Command: Truncate Command Belongs to DDL Can be Used to delete entire Table data Can't be used to delete specific rows using where clause Can't be rolled back Drop Command: Drop Command Belongs to DDL Can be Used to delete entire Table data and also the structure Can't be used to delete specific rows using where clause Can't be rolled back Interview questions and answers – free pdf download Page 3 of 29
  • 4. What Can You Do for Us That Other Candidates Can't? What makes you unique? This will take an assessment of your experiences, skills and traits. Summarize concisely: "I have a unique combination of strong technical skills, and the ability to build strong customer relationships. This allows me to use my knowledge and break down information to be more user-friendly." Interview questions and answers – free pdf download Page 4 of 29
  • 5. What is the difference between primary key and unique key Unique Key: a.A table can contain more than one unique key b.Unique key allows one null value Primary Key: a.A table can contain only one primary key (can be one/more columns) b.Primary key will not allow null values Interview questions and answers – free pdf download Page 5 of 29
  • 6. What is the difference between sub queries and joins a.Sub Queries : To write sub queries between two or more tables, there is no need to be relation exist among those tables b.Joins: To write joins between two or more tables, there should be relation exist among those tables Interview questions and answers – free pdf download Page 6 of 29
  • 7. Write syntax for views and stored procedures View Syntax: Create view <view-name> as select <column names> from <table-name> where <condition> Stored Procedure Sysntax: Create procedure <procedure-name> as begin select <column names> from <table-name> end Note: These are only sample examples, we can write in different ways also. Interview questions and answers – free pdf download Page 7 of 29
  • 8. What are the different constraints available in sql and Explain Not Null -> enforces a column to Not accept Null values Unique -> uniquely identifies each record in a database table Primary Key -> uniquely identifies each record in a database table and it cannot contain NULL values. Foreign Key -> A Foreign Key in one table points to a PRIMARY KEY in another table. Check -> It is used to limit the value range that can be placed in a column. Default -> It is used to insert a default value into a column. Interview questions and answers – free pdf download Page 8 of 29
  • 9. By default how the column data would display if use order by <column> By default the order by would display the data in ascending order Syntax: a. select <col-names> from <table-name> order by <col-names> It will display the results in ascending order select <col-names> from <table-name> order by <col-names> desc It will display the results in descending order select <col-names> from <table-name> order by <col-names> asc It will display the results in ascending order Interview questions and answers – free pdf download Page 9 of 29
  • 10. What is the operator in sql to find pattern match Like Select <colnames> from <table-name> where <col> like <pattern> Ex: a. Select ename from emp where ename like ‘v%’ It will display all the names which are start with ‘v’ b. Select ename from emp where ename not like ‘v%’ It will display other than all the names which are start with ‘v’ Interview questions and answers – free pdf download Page 10 of 29
  • 11. What is the purpose of ‘distinct’ in sql Distinct is used to display only the different values Ex: Select distinct <col-names> from <table-name> Select distinct ename from emp Interview questions and answers – free pdf download Page 11 of 29
  • 12. What is the difference between union and union all The UNION operator selects only distinct values by default. To allow duplicate values, use UNION ALL Select <col-names> from <table1> union select <col-names> from <table2> Select <col-names> from <table1> union all select <col-names> from <table2> Interview questions and answers – free pdf download Page 12 of 29
  • 13. How can I find total number of employees with more than 40 years? SELECT COUNT(EMPLOYEES.*) FROM EMPLOYEES WHERE EMPLOYEES.Age>40 Interview questions and answers – free pdf download Page 13 of 29
  • 14. How to create Identity Column using Query? SELECT row_number() OVER(ORDER by TESTTABLE.p1) as SRNO, result=CASE WHEN TESTTABLE.p1 IS NOT NULL THEN TESTTABLE.p1 WHEN TESTTABLE.p2 IS NOT NULL THEN TESTTABLE.p2 END FROM TESTTABLE Interview questions and answers – free pdf download Page 14 of 29
  • 15. How do I select 2nd highest salaried employee from my EMPLOYEE table? SELECT EMPLOYEE.*, MAX(EMPLOYEE.Salary) AS SalarySecondHighest FROM EMPLOYEE WHERE EMPLOYEE.Salary< (SELECT MAX(EMPLOYEE.Salary) AS SalaryFirstHighest FROM EMPLOYEE) Interview questions and answers – free pdf download Page 15 of 29
  • 16. How to select top 3 employees from EMPLOYEE table which is grouped in the salary groups? SELECT EMPLOYEE.* FROM (SELECT EMPLOYEE.*, rank() OVER(PARTITION BY EMPLOYEE.Salary ORDER BY EMPLOYEE.Salary ASC) AS Rank from EMPLOYEE ) EMPLOYEE where Rank<3 -- if you want to top n employees for each grouped salary -- replace 3 in the query with (n+1) ORDER BY EMPLOYEE.Salary Interview questions and answers – free pdf download Page 16 of 29
  • 17. How to find all the employees from EMPLOYEE table who earns more than the average salary of their department SELECT OUTEREMPLOYEE.*, OUTEREMPLOYEE.Salary FROM EMPLOYEE OUTEREMPLOYEE WHERE OUTEREMPLOYEE.Salary > (SELECT AVG(INNEREMPLOYEE.Salary) FROM EMPLOYEE INNEREMPLOYEE WHERE OUTEREMPLOYEE.DepartmentID = INNEREMPLOYEE.DepartmentID) Interview questions and answers – free pdf download Page 17 of 29
  • 18. How to list employees with period of service in terms of years and months? SELECT EMPLOYEE.*,TO_CHAR(TRUNC( MONTHS_BETWEEN(SYSDATE, EMPLOYEE.HireDate)/12)) AS Years, TO_CHAR(TRUNC( MOD(MO NTHS_BETWEEN(SYSDATE, EMPLOYEE.HireDate),12))) AS Months FROM EMPLOYEE Interview questions and answers – free pdf download Page 18 of 29
  • 19. How to display only Even Records from EMPLOYEE table? SELECT EMPLOYEE.* FROM EMPLOYEE WHERE (rowid,0) in (SELECT rowid,mod(rownum,2) FROM EMPLOYEE) Interview questions and answers – free pdf download Page 19 of 29
  • 20. How to display only Odd Records from EMPLOYEE table? SELECT EMPLOYEE.* FROM EMPLOYEE WHERE (rowid,1) in (SELECT rowid,mod(rownum,2) FROM EMPLOYEE) Interview questions and answers – free pdf download Page 20 of 29
  • 21. What are DDL and DML commands? DDL (DataDifinition Language): Create Alter Truncate Drop DML (Data Manipulation Language): Select Insert Update Deletet Interview questions and answers – free pdf download Page 21 of 29
  • 22. Useful job interview materials: If you need top free ebooks below for your job interview, please visit: 4career.net • Free ebook: 75 interview questions and answers • Top 12 secrets to win every job interviews • Top 36 situational interview questions • 440 behavioral interview questions • 95 management interview questions and answers • 30 phone interview questions • Top 8 interview thank you letter samples • 290 competency based interview questions • 45 internship interview questions • Top 7 cover letter samples • Top 8 resume samples • Top 15 ways to search new jobs Interview questions and answers – free pdf download Page 22 of 29
  • 23. Top 6 tips for job interview Interview questions and answers – free pdf download Page 23 of 29
  • 24. Tip 1: Do your homework You'll likely be asked difficult questions during the interview. Preparing the list of likely questions in advance will help you easily transition from question to question. Spend time researching the company. Look at its site to understand its mission statement, product offerings, and management team. A few hours spent researching before your interview can impress the hiring manager greatly. Read the company's annual report (often posted on the site), review the employee's LinkedIn profiles, and search the company on Google News, to see if they've been mentioned in the media lately. The more you know about a company, the more you'll know how you'll fit in to it. Ref material: 4career.net/job-interview-checklist- 40-points Interview questions and answers – free pdf download Page 24 of 29
  • 25. Tip 2: First impressions When meeting someone for the first time, we instantaneously make our minds about various aspects of their personality. Prepare and plan that first impression long before you walk in the door. Continue that excellent impression in the days following, and that job could be yours. Therefore: · Never arrive late. · Use positive body language and turn on your charm right from the start. · Switch off your mobile before you step into the room. · Look fabulous; dress sharp and make sure you look your best. · Start the interview with a handshake; give a nice firm press and then some up and down movement. · Determine to establish a rapport with the interviewer right from the start. · Always let the interviewer finish speaking before giving your response. · Express yourself fluently with clarity and precision. Useful material: 4career.net/top-10-elements-to-make-a- Interview questions and answers – free pdf download Page 25 of 29
  • 26. good-first-impression-at-a-job-interview Tip 3: The “Hidden” Job Market Many of us don’t recognize that hidden job market is a huge one and accounts for 2/3 of total job demand from enterprises. This means that if you know how to exploit a hidden job market, you can increase your chance of getting the job up to 300%. In this section, the author shares his experience and useful tips to exploit hidden job market. Here are some sources to get penetrating into a hidden job market: Friends; Family; Ex-coworkers; Referral; HR communities; Field communities; Social networks such as Facebook, Twitter…; Last recruitment ads from recruiters; HR emails of potential recruiters… Interview questions and answers – free pdf download Page 26 of 29
  • 27. Tip 4: Do-It-Yourself Interviewing Practice There are a number of ways to prepare for an interview at home without the help of a professional career counselor or coach or a fee-based service. You can practice interviews all by yourself or recruit friends and family to assist you. Useful material: 4career.net/free-ebook- 75-interview-questions-and-answers Interview questions and answers – free pdf download Page 27 of 29
  • 28. Tip 5: Ask questions Do not leave the interview without ensuring that you know all that you want to know about the position. Once the interview is over, your chance to have important questions answered has ended. Asking questions also can show that you are interested in the job. Be specific with your questions. Ask about the company and the industry. Avoid asking personal questions of the interviewer and avoid asking questions pertaining to politics, religion and the like. Ref material: 4career.net/25-questions-to- ask-employers-during-your-job-interview Interview questions and answers – free pdf download Page 28 of 29
  • 29. Tip 6: Follow up and send a thank-you note Following up after an interview can help you make a lasting impression and set you apart from the crowd. Philip Farina, CPP, a security career expert at Manta Security Management Recruiters, says: "Send both an email as well as a hard-copy thank-you note, expressing excitement, qualifications and further interest in the position. Invite the hiring manager to contact you for additional information. This is also an excellent time to send a strategic follow-up letter of interest." Ref material: 4career.net/top-8- interview-thank-you-letter-samples Interview questions and answers – free pdf download Page 29 of 29