SQL Interview Questions
- 0of 0 votes
AnswersHow important do you consider cursors or while loops for a transactional database?
- mythili.vestino April 30, 2021 in India for HR| Report Duplicate | Flag | PURGE
vestino technologies HR Executive SQL - 0of 0 votes
AnswersHow do you generate file output from SQL?
- mythili.vestino April 30, 2021 in India for HR| Report Duplicate | Flag | PURGE
vestino technologies HR Executive SQL - 0of 0 votes
AnswersWhat is the Difference between COALESCE() & ISNULL()?
- mythili.vestino April 30, 2021 in India for HR| Report Duplicate | Flag | PURGE
vestino technologies HR Executive SQL - 0of 0 votes
AnswersCan we add an identity column to decimal datatype?
- mythili.vestino April 30, 2021 in India for HR| Report Duplicate | Flag | PURGE
vestino technologies HR Executive SQL - 0of 0 votes
AnswersIf we drop a table, does it also drop related objects like constraints, indexes, columns, defaults, Views and Stored Procedures?
- mythili.vestino April 30, 2021 in India for HR| Report Duplicate | Flag | PURGE
vestino technologies HR Executive SQL - 0of 0 votes
AnswersCan we write a distributed query and get some data which is located on other server and on Oracle Database ?
- mythili.vestino April 30, 2021 in India for HR| Report Duplicate | Flag | PURGE
vestino technologies HR Executive SQL - 0of 0 votes
AnswersWhat is a stored procedure?
- mythili.vestino April 30, 2021 in India for HR| Report Duplicate | Flag | PURGE
vestino technologies HR Executive SQL - 0of 0 votes
AnswersWhat is a trigger?
- mythili.vestino April 30, 2021 in India for HR| Report Duplicate | Flag | PURGE
vestino technologies HR Executive SQL - 0of 0 votes
AnswersAdvantages and Disadvantages of Stored Procedure?
- mythili.vestino April 30, 2021 in India for HR| Report Duplicate | Flag | PURGE
vestino technologies HR Executive SQL - 0of 0 votes
AnswersWhat is recursive stored procedure?
- mythili.vestino April 30, 2021 in India for HR| Report Duplicate | Flag | PURGE
vestino technologies HR Executive SQL - 0of 0 votes
AnswersWhat are aggregate and scalar functions?
- mythili.vestino April 30, 2021 in India for HR| Report Duplicate | Flag | PURGE
vestino technologies HR Executive SQL - 0of 0 votes
AnswersWhich operator is used in query for pattern matching?
- mythili.vestino April 30, 2021 in India for HR| Report Duplicate | Flag | PURGE
vestino technologies HR Executive SQL - 0of 0 votes
AnswersWhat is the command used to fetch first 5 characters of the string?
- mythili.vestino April 30, 2021 in India for HR| Report Duplicate | Flag | PURGE
vestino technologies HR Executive SQL - 0of 0 votes
Answersthere are 3 tables :
- 11gupt November 11, 2020 in United States
Movie = {movie_id, .....}
Actor = {actor_id, gender, .....}
Movie_Actor = {movie_id, actor_id,....}
Find the pair of movie actor ( male) and actress ( female) who appeared in most movies together.| Report Duplicate | Flag | PURGE
SQL - 0of 0 votes
AnswersTablea Order = {order_id, order_timestamp, total_sale_amount, ....}
- 11gupt November 11, 2020 in United States
Note => Trimmed Mean = remove top and bottom 5 percentile data to remove outliers. Take the average of middle 90% of the data.
you can use function percentile(Col_name, 0.95)
output should look like => {Date, raw_average, trimmed_average}| Report Duplicate | Flag | PURGE
SQL - 0of 0 votes
AnswersHouse No Members
- 11gupt October 10, 2020 in United States
1100 John, mary, kim, ash
1101 Dan, Roger, kee
Write a query to get in below format-
House No Person
1100 john
1100 mary
1100 kim
1100 ash
1101 Dan
1101 roger
1101 kee| Report Duplicate | Flag | PURGE
Data Engineer SQL - 0of 0 votes
AnswersWhile designing a Table in database, how will you determine its performance?
- 11gupt October 10, 2020 in United States| Report Duplicate | Flag | PURGE
Data Engineer SQL - 0of 0 votes
Answersgiven 3 tables:
- crackerfive August 08, 2019 in United States
table_1 has factory, material, date, quantity fields indicating what factory to can produce deliver which material by the specific date.
table_2 has company, material, date, quantity fields indicating what company wants to have some amount of material by the specific date.
table_3 has company, factory, material fields indicating what material a company can buy from which factory.
Write a sql to output a table with company, factory, material, quantity, date fields, for each row, it is the real amount that a factory can deliver to a company
on that date, the quantity might be zero.
If there are more demand than production, a factory takes earlier order or the biggest amount order if both orders have the same demanding date.
sample input
table_1
factory material quantity date
f1 a 100 2010-10-10
f1 b 200 2010-10-10
f1 a 500 2011-11-11
f2 a 300 2010-10-10
table_2
company material quantity date
c1 a 100 2010-10-12
c2 b 200 2010-10-10
c1 a 500 2011-11-11
c3 a 300 2010-10-10
table 3
company factory material
c1 f1 a
c1 f2 a
c2 f1 b
c3 f2 a| Report Duplicate | Flag | PURGE
Apple SQL - 0of 0 votes
AnswersData sets: Bank_Branch(Branch_id, branch_nm), Customer_Branch(cust_id,branch), Deposit_Branch (cust_id,branch_nm,deposit_am)
- HR August 03, 2019 in United States
Question: Find customers who made deposits in all the branches in a given city.| Report Duplicate | Flag | PURGE
None SQL - 0of 0 votes
AnswersGiven user login information - name, event(login/out), event_time. Find hours spend per user. If a hourly rate is given, find the charges per user for given time.
- HR August 03, 2019 in United States| Report Duplicate | Flag | PURGE
None SQL - 0of 0 votes
AnswersYou have a database table that stores information about the price change of various product with time. It's append only table. Whenever the price of the product p1 is changed to c1 at time t1, a new row will be appended.
- neer.1304 April 11, 2019 in United States
product_id price time
p1 10 4
p2 40 4
p1 20 5
p1 25 6
p2 55 7
...
Write an SQL query that will give the price of every product at time t1.
e.g. at time 6
product_id price
p1 25
p2 40
Note: Consider the case where two updates are made at the same time. Don't assume that the table is sorted by time.| Report Duplicate | Flag | PURGE
Walmart Labs SDE-3 SQL - 0of 0 votes
Answer/*
- trish March 19, 2019 in United States
## Setup
The flow of a dispute is as follows:
- A charge is created by an end customer.
- Stripe receives a dispute record from the bank.
- The business responds with evidence.
- If no second dispute is received within 30 days after evidence submission, the dispute is won. If a second dispute is received, the dispute is lost.
Charge
(Maybe) Dispute Record
(Maybe) Evidence submission
(Maybe) Second Dispute Record
The raw tables generated from the API look like:
```
Charges
+---------------+-----------+
| charge_id | varchar |
| created | timestamp |
| amount | int |
| seller_id | varchar |
| customer_id | varchar |
+---------------|-----------+
Dispute Records
+----------------+-----------+
| dispute_id | varchar |
| created | timestamp |
| charge_id | varchar |
+----------------|-----------+
Evidence Submission
+-------------------+-----------+
| evidence_id | varchar |
| created | timestamp |
| charge_id | varchar |
+-------------------|-----------+
```
*/
/*
1. Can you design a unified dispute table that would allow us to compute things like the win rate, dispute rate, evidence submission rate etc?
*/| Report Duplicate | Flag | PURGE
Strip Data Engineer SQL - 0of 0 votes
AnswersWhat are common table expressions? How are they different than temporary tables?
- Jaideep July 18, 2018 in India| Report Duplicate | Flag | PURGE
Deloitte Consulting LLP Applications Developer SQL - 0of 0 votes
AnswersWrite query to find second highest salary? Provide different queries to find using sql.
- Jaideep July 18, 2018 in India| Report Duplicate | Flag | PURGE
Deloitte Consulting LLP Applications Developer SQL - -1of 1 vote
AnswersEmployees Per Department
- aonecoding September 05, 2017 in United States
Twitter Interview Online Test SQL
A company uses 2 data tables, Employee and Department, to store data about its employees and departments.
Table Name: Employee
Attributes:
ID Integer,
NAME String,
SALARY Integer,
DEPT_ID Integer
Table Name: Department
Attributes:
DEPT_ID Integer,
Name String,
LOCATION String
View sample tables:
https://s3-us-west-2.amazonaws.com/aonecode/techblog/50cfcdd1d61f1bd6002cf4d3b4a61deb-min.jpeg
Write a query to print the respective Department Name and number of employees for all departments in the Department table (even unstaffed ones).
Sort your result in descending order of employees per department; if two or more departments have the same number of employees, then sort those departments alphabetically by Department Name.| Report Duplicate | Flag | PURGE
Twitter Software Engineer SQL - 0of 0 votes
AnswersI have two tables
- shopatlemo July 01, 2017 in United States
Supplier Table:
Supp_id
supp_name
Invoice Table:
inv_id
supp_id
inv_date
inv_amt
payment_date
paid_amt
I want to list the invoice(s) that have highest invoice_amt for the year 2016.
DO NOT USE MIN/MAX function| Report Duplicate | Flag | PURGE
Facebook Data Engineer SQL - 1of 1 vote
AnswersTable: Student
- padmarajuharish March 08, 2017 in United States
Fields: Student_ID, Department, Start_Date
ex: 1,A, 2017-01-1
1,B, 2017-07-1
1,C, 2017-12-1
Expected Output: Student_ID, Department, Start_Date, End_Date
ex: 1,A, 2017-01-1, 2017-07-01
1,B, 2017-07-1,2017-12-01
1,C, 2017-12-1, ...
End_Date is the start Date of the next record for the student ID| Report Duplicate | Flag | PURGE
Amazon SQL - 0of 0 votes
Answerstable RSVP
- david October 11, 2016 in United States
Name, Decision, Date
Jon, Y, 1 jan 2016
Jon, N, 2 Jan 2016
Linda, Y, 1 Jan 2016
Mark, Y, 5 Jan 2016
Rob, N, 5 Jan 2016
-- SQL query to find out how many of your friends are coming to party?, make sure that, they haven't said N after saying Y like Jon, check date.
So the answer should be 2| Report Duplicate | Flag | PURGE
ASU SQL - 0of 0 votes
AnswersWrite SQL query to get the earliest flight from A to B.
- zyz February 23, 2016 in United States| Report Duplicate | Flag | PURGE
Google Analyst SQL - 0of 0 votes
AnswersI want to run a function that does that automatically for me until the condition is complete (condition is some update statement),if i have 2000 records and exit when condition should be counter<500;
- sona4144 February 11, 2016 in India
so if i have 2000 records so counter will be 2000/500 =4
loop will execute for 4 times
update statement should consist of
update tablename set counter=1 where rownum<500
this process continues until the update condition is met| Report Duplicate | Flag | PURGE
Analyst SQL