100% found this document useful (1 vote)
2K views

Ey SQL Wriiten Test

The document contains 6 questions for a SQL written test. The questions cover topics like inner and outer joins, indexes, subqueries to find salespeople and orders from given tables, stored procedures, and finding the 2nd highest salary from an employee table.

Uploaded by

NIKHIL AGGARWAL
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
2K views

Ey SQL Wriiten Test

The document contains 6 questions for a SQL written test. The questions cover topics like inner and outer joins, indexes, subqueries to find salespeople and orders from given tables, stored procedures, and finding the 2nd highest salary from an employee table.

Uploaded by

NIKHIL AGGARWAL
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

EY SQL WRIITEN TEST 30/JAN/17(9:15 – 10:15)

Q1)WHAT IS INNER JOIN AND OUTER JOIN?

Q2) WHAT IS INDEX.NAME DIFFERENT TYPES OF INDEXS?

Q3)

Salesperson Customer

ID Name Age Salary ID Name City Industry Type


1 Abe 61 140000 4 Samsonic pleasant J
2 Bob 34 44000 6 Panasung oaktown J
5 Chris 34 40000 7 Samony jackson B
7 Dan 41 52000 9 Orange Jackson B
8 Ken 57 115000
11 Joe 38 38000
Orders

Number order_date cust_id salesperson_id Amount


10 8/2/96 4 2 540
20 1/30/99 4 8 1800
30 7/14/95 9 1 460
40 1/29/98 7 2 2400
50 2/3/98 6 7 600
60 3/2/98 6 7 720
70 5/6/98 9 7 150

Given the tables above, find the following:

a. The names of all salespeople that have an order with Samsonic.

b. The names of all salespeople that do not have any order with Samsonic.

c. The names of salespeople that have 2 or more orders.

d. Write a SQL statement to insert rows into a table called highAchiever(Name, Age),
where a salesperson must have a salary of 100,000 or greater to be included in the
table.
Q4)
User
user_id
name
phone_num

UserHistory
user_id
date
action

1. Write a SQL query that returns the name, phone number and most recent date for any
user that has logged in over the last 30 days (you can tell a user has logged in if the
action field in UserHistory is set to "logged_on").

Every time a user logs in a new row is inserted into the UserHistory table with user_id,
current date and action (where action = "logged_on").

2. Write a SQL query to determine which user_ids in the User table are not contained in
the UserHistory table (assume the UserHistory table has a subset of the user_ids in User
table). Do not use the SQL MINUS statement. Note: the UserHistory table can have
multiple entries for each user_id.

Q5) WRITE A STORED PROCEDURE TO INVERT THE STRING ‘ERNST AND YOUNG’ AS ‘GNUOY DNA
TSNRE’

Q6)WRITE A QUERY TO DISPLAY THE 2ND HIGHEST SAL OF EMPLOYEE IN EMPLOYEE TABLE.

You might also like