At Cirrus Logic, SQL is used all the damn time for analyzing complex semiconductor data for product performance optimization. Because of this, Cirrus Logic frequently asks SQL query questions during interviews for Data Analyst, Data Science, and BI jobs.
So, to help you practice for the Cirrus Logic SQL interview, this blog covers 10 Cirrus Logic SQL interview questions – can you answer each one?
In Cirrus Logic, the HR department is analyzing the salary changes of employees to measure the growth of salaries over time. You are required to write a SQL query which gives the details of each employee with their current salary, the previous salary, as well as the percentage increase or decrease from their previous salary.
Consider the following table :
emp_id | date_issued | salary |
---|---|---|
E001 | 06/01/2020 | 70000 |
E001 | 06/01/2021 | 78000 |
E002 | 06/01/2020 | 85000 |
E002 | 03/01/2022 | 95000 |
emp_id | date_issued | curr_salary | prev_salary | salary_percent_change |
---|---|---|---|---|
E001 | 06/01/2021 | 78000 | 70000 | 11.42857 |
E002 | 03/01/2022 | 95000 | 85000 | 11.76470 |
For each employee, you should return their id, date when the salary was assigned, current salary, previous salary, and the percent change from the previous salary.
In this query, we first create a table where for each date we have the previous salary of the employee using the LAG function. Then we join this with the original table to calculate the percentage increase. The last WHERE clause is included to exclude any row where the employee did not have a previous salary (e.g., the salary of the first date for each employee).
To solve a related window function SQL problem on DataLemur's free online SQL code editor, solve this Amazon BI Engineer interview question:
Cirrus Logic is a company specialising in manufacturing of precision integrated circuits. They want to set up a database system to manage their inventory of different types of integrated circuits. The inventory system should be capable of tracking different types of chips, their corresponding manufacturer information, quantities in stock, and their corresponding costs.
The tables required would be as follows:
manufacturer_id | manufacturer_name |
---|---|
101 | Samsung |
102 | Intel |
103 | AMD |
chip_type_id | chip_type_name | manufacturer_id |
---|---|---|
2001 | Processor | 102 |
2002 | Graphics | 103 |
2003 | Memory | 101 |
inventory_id | chip_type_id | quantity | cost_per_unit |
---|---|---|---|
3050 | 2001 | 1000 | 120 |
3051 | 2002 | 500 | 200 |
3052 | 2003 | 2000 | 80 |
To assess the total cost of inventory for each type of chips, you can use the following SQL query:
This query joins and on , and on to get the required information. A computed column is added by multiplying with . Useful when the management needs an overview of the worth of the stock of each type of chip in the inventory.
A is a field in a table that references the of another table. It creates a link between the two tables and ensures that the data in the field is valid.
Say for example you had sales analytics data from Cirrus Logic's CRM (customer-relationship management) tool.
In this example, the table has a foreign key field called that references the "account_id" field in the table (the primary key). This helps to link the data about each opportunity to the corresponding account information in the accounts table.
This makes sure the insertion of rows in the table that do not have corresponding entries in the table. It also helps to enforce the relationship between the two tables and ensures that data is not deleted from the table if there are still references to it in the table.
Suppose at Cirrus Logic, the HR department wants to evaluate the compensation distribution in the company. They are interested to know the average salary for each position in the company. Assume there are two relevant tables and .
employee_id | position |
---|---|
1001 | Software Engineer |
1002 | Data Analyst |
1003 | Software Engineer |
1004 | Product Manager |
1005 | Data Analyst |
employee_id | salary |
---|---|
1001 | 80000 |
1002 | 70000 |
1003 | 90000 |
1004 | 120000 |
1005 | 70000 |
For simplicity, assume salaries are annual and in USD.
This query first joins the table with table on the column. It then groups the resulting table by and calculates the average salary for each group. So, it ultimately gives the average salary for each position in the company. The function in SQL is used to calculate average of a set of values. The statement groups rows that have the same values in specified columns into aggregated data.
The 2 most similar questions are:
"Highest-Grossing Items" - This deals with calculating the top items within each category from a given table. This is analogous to calculating the average salary for each position.
"Average Review Ratings" - This deals with calculating the average rating for each product, which is similar to calculating the average salary for each position.
Please find below the markdown-friendly output:
To practice a very similar question try this interactive Amazon Highest-Grossing Items Question which is similar because it involves calculating top entries per category or this Amazon Average Review Ratings Question which is similar because it involves calculating averages for different categories.
"The clause in SQL allows you to select records that are unique, eliminating duplicates.
For a tangible example, say you had a table of Cirrus Logic employees:
first_name | job_title |
---|---|
Akash | Data Analyst |
Brittany | Data Scientist |
Carlos | Data Engineer |
Diego | Data Engineer |
Eva | Data Analyst |
If you were doing an HR Analytics project and you wanted to get all the unique job titles that currently worked at the company, you would write the following SQL query:
The output would give you 3 distinct job titles at Cirrus Logic:
job_title |
---|
Data Analyst |
Data Scientist |
Data Engineer |
Cirrus Logic, Inc. is a prominent American fabless semiconductor supplier specializing in analog, mixed-signal, and audio DSP integrated circuits (ICs). To better understand their customers' engagement with their digital marketing campaigns, they track various metrics, including the click-through rates of their product advertisements.
Given the following tables of and , calculate the click-through rate per product for the month of July. Click-through rate (CTR) is calculated as the total number of clicks that your ad receives divided by the total number of people who see your ad (impressions).
ad_id | product_id | impressions | month |
---|---|---|---|
1 | 101 | 15000 | 7 |
2 | 102 | 12000 | 7 |
3 | 103 | 13000 | 7 |
4 | 101 | 16000 | 8 |
5 | 102 | 11000 | 8 |
6 | 103 | 15000 | 8 |
click_id | ad_id | user_id | click_date |
---|---|---|---|
1 | 1 | 201 | 07/01/2022 |
2 | 1 | 202 | 07/02/2022 |
3 | 2 | 203 | 07/03/2022 |
4 | 2 | 204 | 07/04/2022 |
5 | 3 | 205 | 07/05/2022 |
6 | 3 | 206 | 07/06/2022 |
This query first joins the table with the table using the . It restricts the data to the month of July using a clause. It calculates the click-through rate as the count of click ids divided by the sum of impressions for each product, which is aggregated by . The result is the click-through rates for each product in the month of July.
To solve a similar SQL interview question on DataLemur's free interactive SQL code editor, solve this SQL interview question asked by Facebook:
Stored procedures are a lot like functions in programming. They're used to encapsulate and organize business logic into one unit of code, and they can accept multiple input parameters and return multiple output values.
For example, if you were a Data Analyst at Cirrus Logic working on a HR analytics project, you might create a stored procedure to calculate the average salary for a given department:
To call this stored procedure and find the average salary for the Data Analytics department you'd write the following query:
Cirrus Logic is an American fabless semiconductor supplier that specializes in analog, mixed-signal, and audio DSP integrated circuits. As a data analyst, you have been asked to figure out the total quantity of products sold and the total amount from the sales of each product for this month.
You have access to two tables: and . The table has information about the product id, the product name and its price. The table lists each sale made, including the product id, the quantity of products sold, and the date of the sale.
Use SQL to join these tables and calculate the required total quantity sold and the total sale amount.
product_id | product_name | product_price |
---|---|---|
101 | Product A | 100 |
102 | Product B | 200 |
103 | Product C | 300 |
104 | Product D | 400 |
105 | Product E | 500 |
|sale_id|product_id|date|quantity| |:-------------|:-----------|:----------|:--------|:------- |201|101|01/20/2023|20| |202|102|01/21/2023|25| |203|103|01/22/2023|30| |204|101|01/23/2023|20| |205|102|01/24/2023|25| |206|104|01/25/2023|30|
The SQL query above performs an INNER JOIN between the and tables using the field which is common to both tables. It also swathes where conditions to ensure that only the transactions within the current month are considered. Within the SELECT statement, we have used SQL aggregate functions SUM() to calculate both the total quantity sold (by summing up the quantity column) and the total sales amount (by multiplying the quantity sold with the product price). Lastly, the GROUP BY clause is used to summarize the results per product.
Because join questions come up routinely during SQL interviews, take a stab at this Snapchat JOIN SQL interview question:
Cirrus Logic is working on an energy management project where they collect data from thousands of devices. They need to calculate how much energy each device uses on a daily basis. The energy usage of a device is calculated by the formula:
This needs to be rounded off to the nearest whole number. The company also wants to calculate the total cumulative energy usage of all the devices together.
Given the table, write a SQL query to calculate the energy usage of each device and the total cumulative energy usage.
This SQL query first calculates the energy usage of each device using the given formula and rounding off the result. The UNION ALL operator is used to combine these results with the total cumulative energy usage calculations. GROUP BY is used on the date column to get separate readings for each date and the results are ordered by date and device id for readability.
To practice a very similar question try this interactive Amazon Server Utilization Time Question which is similar for calculating total utilization or this Google Odd and Even Measurements Question which is similar for using formula to calculate measurement.
The CHECK constraint is used to set a rule for the data in a column. If a row is inserted or updated and the data in the column does not follow the rule specified by the CHECK constraint, the operation will be unsuccessful.
For example, say you had Cirrus Logic customer data. You could use a CHECK constraint to ensure that the email column contains only properly formatted email addresses, or that the age column contains only positive integer. Here's an example of that:
The best way to prepare for a Cirrus Logic SQL interview is to practice, practice, practice. Beyond just solving the earlier Cirrus Logic SQL interview questions, you should also solve the 200+ DataLemur SQL Interview Questions which come from companies like Facebook, Google and unicorn tech startups.
Each exercise has hints to guide you, full answers and most importantly, there's an interactive SQL code editor so you can instantly run your SQL query answer and have it checked.
To prep for the Cirrus Logic SQL interview you can also be useful to solve SQL questions from other tech companies like:
However, if your SQL coding skills are weak, forget about jumping right into solving questions – refresh your SQL knowledge with this free SQL tutorial.
This tutorial covers SQL topics like WHERE vs. HAVING and CASE/WHEN/ELSE statements – both of these show up routinely during Cirrus Logic SQL interviews.
In addition to SQL interview questions, the other question categories tested in the Cirrus Logic Data Science Interview are:
To prepare for Cirrus Logic Data Science interviews read the book Ace the Data Science Interview because it's got: