11 Photronics SQL Interview Questions (Updated 2024)

Updated on

June 23, 2024

At Photronics, SQL used for querying and manipulating the semiconductor manufacturing database records, and extracting customer order trends and metrics for strategic decision-making based on historical data. That's why Photronics often tests SQL questions in interviews for Data Science and Data Engineering positions.

So, to help you study for the Photronics SQL interview, here's 11 Photronics SQL interview questions can you solve them?

11 Photronics SQL Interview Questions

SQL Question 1: Calculate Total Sales for each Product per month.

Working at Photronics, a manufacturing company that sells a variety of materials and products, you're given a task to calculate the total sales for each product per month using the dataset.

Example Input:


You're asked to write a SQL query to provide a report displaying the total sales (calculated as ) of each product for each month.

Example Output:


This query uses the PostgreSQL window function to calculate the total sales of each product for each month. The function is used to pull the month from the . The clause is used to organize the sales per product by month. The clause then sorts the result in ascending order by month, and descending order by total sales.

To practice another window function question on DataLemur's free interactive SQL code editor, solve this Google SQL Interview Question: Google SQL Interview Question

SQL Question 2: Top Three Salaries

Given a table of Photronics employee salary data, write a SQL query to find the top 3 highest paid employees within each department.

Photronics Example Input:

1Emma Thompson38001
2Daniel Rodriguez22301
3Olivia Smith20001
4Noah Johnson68002
5Sophia Martinez17501
8William Davis68002
10James Anderson40001

Example Input:

1Data Analytics
2Data Science

Example Output:

Data AnalyticsJames Anderson4000
Data AnalyticsEmma Thompson3800
Data AnalyticsDaniel Rodriguez2230
Data ScienceNoah Johnson6800
Data ScienceWilliam Davis6800

Code your solution to this interview question interactively on DataLemur:

Top 3 Department Salaries


We use the DENSE_RANK() window function to generate unique ranks for each employee's salary within their department, with higher salaries receiving lower ranks. Then, we wrap this up in a CTE and filter the employees with a ranking of 3 or lower.

If the code above is tough, you can find a step-by-step solution here: Top 3 Department Salaries.

SQL Question 3: Can you list the various types of joins in SQL, and describe their purposes?

Joins in SQL allow you to combine data from different tables based on a shared key or set of keys.

Four JOIN types are available in SQL. For an example of each one, say you had sales data exported from Photronics's Salesforce CRM stored in a PostgreSQL database, and had access to two tables: and .

  • : retrieves rows from both tables where there is a match in the shared key or keys. For example, an INNER JOIN between the Sales table and the Customers table would retrieve only the rows where the customer_id in the Sales table matches the customer_id in the table.
  • : retrieves all rows from the left table (in this case, the sales table) and any matching rows from the right table (the table). If there is no match in the right table, NULL values will be returned for the right table's columns.
  • : retrieves all rows from the right table (in this case, the customers table) and any matching rows from the left table (the sales table). If there is no match in the left table, NULL values will be returned for the left table's columns.
  • : retrieves all rows from both tables, regardless of whether there is a match in the shared key or keys. If there is no match, NULL values will be returned for the columns of the non-matching table.

Photronics SQL Interview Questions

SQL Question 4: Analyzing Top Selling Photos

Photronics is a platform that allows photographers to sell their photos online. They have two core tables, and . In the table, each photo has an auto incremented unique , (the id of the author of the photo), and (the date the photo was uploaded). In the table, each sale has a unique , (the id of the photo that was sold), (the id of the customer who bought the photo), and (the date the photo was sold).

The problem is to write a query that shows the top 3 authors who have sold the most photos in the last 30 days, along with the total number of photos they sold.

Example Input:

Example Input:


This SQL script counts the number of sales for each author and orders them by the sale count in descending order. The LIMIT operator is used to select only the top 3 authors.

This query first joins the table with the table on the column. It then filters out sales that happened more than 30 days ago. After that, it groups the remaining rows by author_id and counts the number of sales for each. Finally, it orders the authors by their sale count in descending order and returns the top 3.

SQL Question 5: How can you select records without duplicates from a table?

The keyword removes duplicates from a query.

Suppose you had a table of Photronics customers, and wanted to figure out which cities the customers lived in, but didn't want duplicate results.



You could write a query like this to filter out the repeated cities:

Your result would be:


SQL Question 6: Filter Customer Records for Photronics

Photronics, a company dealing in optical lithography solutions, wants to filter its customer records to identify customers who have ordered educational books the most in the past quarter, between March 1, 2022 and May 31, 2022. They are specifically interested in customers who are from California, USA and have spent at least $100. Using the and table below, write a SQL query to retrieve the desired information.

Example Input:
2JaneSmithNew YorkUSA
Example Input:
order_idcustomer_idorder_dateproduct_typeorder_amount ($)
101103/02/2022Education Books120
102203/15/2022Science Books110
103304/10/2022Education Books105
104504/25/2022Education Books150
105305/10/2022Education Books95
106105/25/2022Education Books130
107503/10/2022Health Books90


This query first combines the and table using a JOIN statement to find records with the matching . Then, it filters the data for customers who live in California, USA, have ordered 'Education Books' between March 1, 2022, and May 31, 2022, and spent at least $100. It groups the results by , , and , then it calculates the total amount spent by each unique customer. Finally, it returns the list of customers ordered by in descending order, meaning customers who spent most will be at the top.

SQL Question 7: How do you determine which records in one table are not present in a second table?

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 is an example using two tables, Photronics employees and Photronics managers:

This will return all rows from Photronics 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 retrieve all rows from employees that do not appear in managers. The operator works by retreivingthe rows that are returned by the first query, but not by the second.

Please note that is not supported by all DBMS systems, such as MySQL and Oracle (however, you can use the operator to achieve a similar outcome).

SQL Question 8: Average Number of Products Sold Per Order

As a database manager at Photronics, a company that sells various types of photographic equipment and supplies, you are asked to evaluate the average number of products sold per order in the last six months to help understand customer purchasing behaviour and optimize inventory management. Using their order history, can you write a query to find this information?

Example Input:


Example Output:



This query first filters orders from the last six months using the WHERE clause. It then calculates the average quantity of products per order using the AVG() function over the column.. Note that here the average is over all orders, if you want to get the average per unique (in case of, say, multiple entries for a single order with different products), you would need to slightly adjust the query.

To practice a very similar question try this interactive Alibaba Compressed Mean Question which is similar for calculating mean order statistics or this Walmart Histogram of Users and Purchases Question which is similar for <evaluating total number of products purchased per user.

SQL Question 9: Highest Selling Camera per Month

You are a Data Analyst at Photronics, a company that sells various brands of digital cameras. The company wants to find out which camera model has generated the highest revenue each month so they can better align their marketing strategy. Write a SQL query that will provide this information. Assume you have access to the transactions table, which has the following columns: {#Question-9}

  • : unique identifier for each transaction
  • : unique identifier for each customer
  • : unique identifier for each camera model
  • : date of the transaction
  • : number of cameras sold in the transaction
  • : selling price of each camera

Provide results for the year 2022. Your output table should include the month, camera_id, and total revenue for that camera for the respective month.

Example Input
Example Output


The query calculates total revenue for each camera every month by using the sum of the times the . It groups the results by and and it only considers the data from 2022. The result is then sorted by and in descending order by to easily identify the camera with the highest revenue each month.

SQL Question 10: What is the purpose of the UNIQUE constraint?

A UNIQUE constraint ensures that all values in a column are different. It is often used in conjunction with other constraints, such as NOT NULL, to ensure that the data meets certain conditions.

For example, if you had Photronics employee data stored in a database, here's some constraints you'd use:

In the Photronics employee example, the UNIQUE constraint is applied to the "email" field to ensure that each employee has a unique email address. This helps to ensure the integrity of the data in the database and prevents errors that could occur if two employees had the same email address.

SQL Question 11: Filtering Customer Records

As a part of the data science team of Photronics, a company dealing with photographic equipment, you are required to generate a list of customers based on their purchasing habits.

The aim here is to find out the customer records whose first_name starts with letter 'J' and has made a purchase in the last 3 months. From your customer and purchases tables, can you crate a SQL query to fetch these records?

Example Input:
Example Input:
837435407/22/2022 00:00:0056921200
562158706/10/2022 00:00:0047812105
495396104/18/2022 00:00:0058901270
847642809/15/2022 00:00:0036842180
750667208/05/2022 00:00:0069876225


This query first creates a join between the customers and purchases tables based on the 'customer_id'. With the WHERE clause, it applies a filter to limit the results only to the customers whose first_name starts with 'J' and made a purchase within the last 3 months. Dates are compared using the 'date_trunc' function. 'CURRENT_DATE - interval '3 months'' gives the date 3 months ago and 'date_trunc' rounds it down to the first day of that month.

Preparing For The Photronics SQL Interview

The key to acing a Photronics SQL interview is to practice, practice, and then practice some more! Besides solving the above Photronics SQL interview questions, you should also solve the 200+ DataLemur SQL Interview Questions which come from companies like Google, Microsoft and Silicon Valley startups. DataLemur SQL and Data Science Interview Questions

Each exercise has hints to guide you, step-by-step solutions and most importantly, there's an interactive coding environment so you can easily right in the browser your SQL query and have it executed.

To prep for the Photronics SQL interview you can also be helpful to solve SQL questions from other tech companies like:

However, if your SQL skills are weak, forget about diving straight into solving questions – strengthen your SQL foundations with this SQL tutorial for Data Analytics.

DataLemur SQL Course

This tutorial covers topics including window functions and CTE vs. Subquery – both of which pop up routinely in SQL job interviews at Photronics.

Photronics Data Science Interview Tips

What Do Photronics Data Science Interviews Cover?

In addition to SQL query questions, the other topics to prepare for the Photronics Data Science Interview include:

Photronics Data Scientist

How To Prepare for Photronics Data Science Interviews?

I'm a tad biased, but I believe the best way to study for Photronics Data Science interviews is to read my book Ace the Data Science Interview.

The book solves 201 interview questions sourced from Google, Microsoft & tech startups. It also has a crash course covering Stats, ML, & Data Case Studies. And finally it's helped a TON of people, which is why it's earned 1000+ reviews on Amazon and a 4.5-star rating.

Ace the Data Science Interview by Nick Singh Kevin Huo