0% found this document useful (0 votes)
2 views

SQL Interview Question

Uploaded by

vishakha chavan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

SQL Interview Question

Uploaded by

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

SQL

Interview questions
for Data Analysts
Part II

linkedin.com/in/ileonjose
1. Find Customers with Specific
Email Providers

Problem Statement: List all customers


whose email addresses use a specific
email provider, such as Gmail. The
customer data is stored in a table with
customer IDs, names, and email
addresses.

linkedin.com/in/ileonjose
How to Solve:

Use the LIKE operator to filter email


addresses by provider.

Use % as a wildcard to match any


email address ending with the
specified provider.

linkedin.com/in/ileonjose
linkedin.com/in/ileonjose
2. How Does the CHECK
Constraint Function?

Problem Statement: Explain the CHECK


constraint in SQL and provide an example
of how it can be used to ensure data
integrity.

linkedin.com/in/ileonjose
How to Solve:

Define the CHECK constraint as a rule


applied to column values.

Provide examples to show its usage in


maintaining data quality, such as
ensuring positive values or date
ranges.

linkedin.com/in/ileonjose
linkedin.com/in/ileonjose
3. Calculate Average Card Usage
Per Month

Problem Statement: Find the average


transaction cost per cardholder for each
month. The transactions are recorded in a
table with transaction IDs, cardholder
IDs, transaction dates, and transaction
costs.

linkedin.com/in/ileonjose
How to Solve:

Extract month from transaction_date.

Group by month and card_holder_id.

Calculate the average transaction cost


for each cardholder each month.

linkedin.com/in/ileonjose
linkedin.com/in/ileonjose
4. Calculating Click-Through-Rate for
Marketing Campaigns

Problem Statement: Calculate the click-


through rate (CTR) for each marketing
campaign. CTR is the ratio of the number
of clicks to the number of views,
expressed as a percentage. You have two
tables: campaigns and clicks.

linkedin.com/in/ileonjose
linkedin.com/in/ileonjose
How to Solve:

Join the campaigns and clicks tables


on campaign_id.

Count 'Clicked' and 'Viewed' actions


for each campaign.

Calculate CTR as (Clicked / Viewed) *


100.

linkedin.com/in/ileonjose
linkedin.com/in/ileonjose
5. Distinction Between Cross Join and
Natural Join

Problem Statement: Explain the


difference between a cross join and a
natural join. Provide examples for both
types of joins.

linkedin.com/in/ileonjose
How to Solve:

Define cross join (Cartesian product)


and natural join (based on common
columns).

Provide example queries for each type


of join to illustrate the differences.

linkedin.com/in/ileonjose
Found this helpful? Repost!

linkedin.com/in/ileonjose

You might also like