logo

9 Nykaa SQL Interview Questions (Updated 2024)

Updated on

March 2, 2024

At Nykaa, SQL does the heavy lifting for analyzing customer purchase patterns and managing inventory data for beauty and fashion products. So, it shouldn't surprise you that Nykaa frequently asks SQL coding questions in interviews for Data Science and Data Engineering positions.

Thus, to help you prepare for the Nykaa SQL interview, here’s 9 Nykaa SQL interview questions – able to answer them all?

9 Nykaa SQL Interview Questions

SQL Question 1: Identify Whale Users for Nykaa

Nykaa is an online retail company that sells beauty and wellness products. The business considers a "Whale User" to be a user who makes purchases frequently (say more than 4 orders a month) and whose total transaction value is high (say, more than $1,000 a month). Write a SQL query that identifies these Whale Users.

Example Input:
order_iduser_idorder_datetotal_amount
27691206/08/2022220
34124506/10/2022500
98941206/11/2022255
34633306/15/2022450
17754506/24/20221200
39321206/25/2022190
21134506/30/2022400
Example Input:
user_iduser_name
12Alice
33Bob
45Charlie

Answer:


This query starts by grouping by and then, using the clause, filters out users who haven't made more than 4 orders and whose total transaction value is less than 1000 in the current month. Next, the query uses a join to derive the user_name for those user_ids from the table. The result will be a list of whale users' ids and names who fulfill both conditions (number of orders and transaction value).

To practice a related customer analytics question on DataLemur's free interactive coding environment, try this Microsoft Teams Power User SQL Interview Question: Microsoft SQL Interview Question: Teams Super User

SQL Question 2: Calculate Monthly Average Ratings

Nykaa is a multi-brand beauty retailer selling cosmetic and wellness products. As a data analyst, you are tasked with analyzing product reviews. You are to provide a breakdown of the average ratings a product receives each month.

Example Input:
review_iduser_idsubmit_dateproduct_idstars
1234782022-01-150015
2345892022-01-200024
3456902022-01-300013
4567912022-02-010012
5678922022-02-050025
6789932022-02-250014
7890942022-02-280023
8901952022-03-010014
9012962022-03-150025
0123972022-03-300012

The output should give the product id, the month, and the average rating for that month.

Example Output:
product_idmonthavg_rating
00114.00
00214.00
00123.00
00224.00
00133.00
00235.00

Answer:


This PostgreSQL query uses the , , , and SQL functions to calculate and display the average rating per product per month. The function is used to compute the average rating, while the function is utilized to get the month part from the . The results are then grouped by and and presented in ascending order based on the and .

To solve a related window function SQL problem on DataLemur's free interactive coding environment, solve this Google SQL Interview Question: Google SQL Interview Question

SQL Question 3: DBMS transactions are expected to follow the ACID properties. What are they, and what does each property mean?

ACID refers to the four key properties that are essential to the reliable and correct execution of database transactions. These properties are:

Atomicity: ensures that a transaction is treated as a single operation, and either all of the changes are made or none of them are! Basically, the database version of a "-FULL SEND-"

Consistency: ensures that the data is in a consistent state before and after a transaction is completed. For example, if wiring money to a friendly Nigerian prince whose fallen on hard times, consistency ensures that the total value of funds lost in my account is the same amount that's gained in the prince's account!

Isolation: ensures that the intermediate state of a transaction is invisible to other transactions. Back to the wiring-the-prince-some-money example, isolation ensures that another transaction sees the transferred funds in my account OR the princes, but not in both accounts at the same time

Durability: ensures that once a transaction has been completed successfully, the changes made by the transaction are permanent and cannot be undone, even in the event of a system failure. Basically, no taksies backsies (even if your system has a meltdown!).

Nykaa SQL Interview Questions

SQL Question 4: Product Popularity

Nykaa, a leading beauty and wellness e-commerce platform, is tempting to analyze how well their diversified range of products are performing. To do this, you need to design a database schema that models , and . Nykaa is mainly interested in finding out the top 5 popular products, determined by the amount of unique users purchasing each product. Design the database tables considering these needs, create sample data, and write a SQL query to find the top 5 products accompanied by the number of unique users who purchased them.

Example Input:
user_iduser_nameemailjoin_date
1John Doejohn_doe@example.com2021-08-01
2Jane Doejane_doe@example.com2021-09-01
3Sam Smithsam_smith@example.com2022-01-01
Example Input:
product_idproduct_nameprice
100Lipstick A500
200Eye Pencil B300
300Foundation C1000
Example Input:
purchase_iduser_idproduct_idpurchase_date
111002022-01-15
222002022-02-18
312002022-03-15
433002022-04-18
523002022-05-15

Answer:


The above query joins the and tables on , and then groups by and to get the count of unique users who have made purchases. The results are then ordered by the count of unique user purchases in descending order to get the top 5 popular products. It returns the product id and name, along with the number of unique users who have made purchases.

SQL Question 5: Can you describe the concept of a database index and the various types of indexes?

An index in a database is a data structure that helps to quickly find and access specific records in a table.

For example, if you had a database of Nykaa customers, you could create a primary index on the column.

Having a primary index on the column can speed up performance in several ways. For example, if you want to retrieve a specific customer record based on their , the database can use the primary index to quickly locate and retrieve the desired record. The primary index acts like a map, allowing the database to quickly find the location of the desired record without having to search through the entire table.

Additionally, a primary index can also be used to enforce the uniqueness of the column, ensuring that no duplicate values are inserted into the table. This can help to prevent errors and maintain the integrity of the data in the table.

SQL Question 6: Nykaa Customer Behavior Analysis

You are a data analyst at Nykaa, an online cosmetic and wellness retailer. Management wants to know the behavior of the customers who have made repeated purchases in the last year but have not made any purchase in the last 3 months. Additionally, they are interested in customers who have their total purchase amount greater than $1000.

Create a SQL query to extract the required details. The major filter clauses being:

  • The customer has made purchases in the last year
  • The customer has not made any purchase in the last 3 months
  • The total purchase amount of the customer is greater than '1000'

The table is given below:

Table:
order_idcustomer_idorder_dateproduct_idamount
10150108/13/202160001200
10255203/19/202265052150
10371207/09/202160001250
10450112/11/202165052300
10555201/05/202260001400
10650107/26/202160001350

Answer:


This query first filters out the records where the order date lies between the last year and the last 3 months. It then groups the records by customer_id and calculates the total purchase amount of each customer. Lastly, it uses the HAVING clause to retain only those records where the total amount of purchase is greater than 1000.

SQL Question 7: What is the process for finding records in one table that do not exist in another?

To find records in one table that aren't in another, you can use a and check for values in the right-side table.

Here's an example using two tables, Nykaa employees and Nykaa managers:


This query returns all rows from Nykaa employees where there is no matching row in managers based on the column.

You can also use the operator in PostgreSQL and Microsoft SQL Server to return the records that are in the first table but not in the second. Here is an example:


This will return all rows from employees that are not in managers. The operator works by returning the rows that are returned by the first query, but not by the second.

Note that isn't supported by all DBMS systems, like in MySQL and Oracle (but have no fear, since you can use the operator to achieve a similar result).

SQL Question 8: Nykaa's Click-Through Rate Analysis

Nykaa is an Indian retail seller of beauty, wellness, and fashion products. As a data analyst for Nykaa, you are tasked to analyze the click-through rates (CTR) of their digital ads to help improve their marketing strategy.

Here's your task: Calculate the click-through rate for each ad. Click-through rate (CTR) is calculated as the number of users who clicked on the ad divided by the number of total ad impressions.

Use the following tables:

:

ad_idimpression_dateviews
10102/02/20225000
10202/05/20226500
10302/10/20228000
10402/15/20227500
10502/20/20227000

:

click_idad_idclick_dateuser_id
11110102/03/2022301
11210102/03/2022302
11310202/06/2022303
11410202/06/2022304
11510302/11/2022305

The ad IDs in both the tables correspond to the same ad.

Answer:

Here is the SQL query in PostgreSQL that you can use to answer the question:


This query calculates the total ad impressions for each ad, the total clicks each ad got, and then calculates the clickthrough rate (ctr) using these two values. The ctr is calculated as the number of clicks divided by the total impressions multiplied by 100 to get a percentage. The LEFT JOIN ensures that even ads with no clicks are included in the result.

To solve a similar problem about calculating rates, solve this TikTok SQL question within DataLemur's online SQL code editor: Signup Activation Rate SQL Question

SQL Question 9: Analyze customers' purchase and review data

Assume a company named Nykaa runs an online store that sells beauty products. They have two tables, one is and another is . In the table, each row represents a unique customer with fields: customer_id, first_name, and last_name. In the table, each row describes a product purchased by a customer, with fields: purchase_id, customer_id, product_id, purchase_date, and review_stars (a rating given by the customer for the purchased product).

The task is to write a SQL query that brings together these two tables to show the first and last names of customers along with the IDs and review_stars of products they purchased.

Example Input:
customer_idfirst_namelast_name
101EmmaJohnson
102OliviaWilliams
103AvaJones
Example Input:
purchase_idcustomer_idproduct_idpurchase_datereview_stars
1001101200107/01/20225
1002102200207/02/20224
1003101200307/03/20223
Example Output:
first_namelast_nameproduct_idreview_stars
EmmaJohnson20015
OliviaWilliams20024
EmmaJohnson20033

Answer:


This query performs an INNER JOIN operation on the two tables using the field. It then selects the and columns from the table and the and columns from the table, producing a result that shows every customer's full name along with the product IDs and review stars for the products they have purchased.

Since join questions come up routinely during SQL interviews, try this Spotify JOIN SQL question: Spotify JOIN SQL question

Nykaa SQL Interview Tips

The best way to prepare for a SQL interview, besides making sure you have strong SQL fundamentals, is to practice a ton of real SQL questions that were asked in recent job interviews. Besides solving the earlier Nykaa SQL interview questions, you should also solve the 200+ FAANG SQL Questions on DataLemur which come from companies like Amazon, Microsoft, Meta, and smaller tech companies. DataLemur Question Bank

Each SQL question has multiple hints, detailed solutions and most importantly, there's an interactive coding environment so you can right online code up your query and have it checked.

To prep for the Nykaa SQL interview it is also useful to solve SQL questions from other tech companies like:

In case your SQL coding skills are weak, don't worry about going right into solving questions – go learn SQL with this SQL interview tutorial.

SQL tutorial for Data Scientists & Analysts

This tutorial covers topics including filtering data with WHERE and 4 types of JOINS – both of which show up frequently during SQL job interviews at Nykaa.

Nykaa Data Science Interview Tips

What Do Nykaa Data Science Interviews Cover?

Besides SQL interview questions, the other topics covered in the Nykaa Data Science Interview are:

Nykaa Data Scientist

How To Prepare for Nykaa Data Science Interviews?

The best way to prepare for Nykaa Data Science interviews is by reading Ace the Data Science Interview. The book's got:

  • 201 Interview Questions from Microsoft, Amazon & startups
  • A Crash Course covering Python, SQL & ML
  • Great Reviews (900+ reviews, 4.5-star rating)

Ace the Data Science Interview by Nick Singh Kevin Huo