# 10 Cirrus Logic SQL Interview Questions (Updated 2024)

Updated on

March 2, 2024

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?

## 10 Cirrus Logic SQL Interview Questions

### SQL Question 1: Analysing Employee Salary Change Over Time

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 :

##### Example Input:
emp_iddate_issuedsalary
E00106/01/202070000
E00106/01/202178000
E00206/01/202085000
E00203/01/202295000
##### Example Output:
emp_iddate_issuedcurr_salaryprev_salarysalary_percent_change
E00106/01/2021780007000011.42857
E00203/01/2022950008500011.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:

### SQL Question 2: Design and Query an Inventory Management System

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:

##### Table:
manufacturer_idmanufacturer_name
101Samsung
102Intel
103AMD
##### Table:
chip_type_idchip_type_namemanufacturer_id
2001Processor102
2002Graphics103
2003Memory101
##### Table:
inventory_idchip_type_idquantitycost_per_unit
305020011000120
30512002500200
30522003200080

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.

### SQL Question 3: Can you explain the purpose of the constraint?

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.

### SQL Question 4: Average Salary for Different Positions

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 .

##### Example Input:
employee_idposition
1001Software Engineer
1002Data Analyst
1003Software Engineer
1004Product Manager
1005Data Analyst
##### Example Input:
employee_idsalary
100180000
100270000
100390000
1004120000
100570000

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:

1. "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.

2. "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.

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

"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_namejob_title
AkashData Analyst
BrittanyData Scientist
CarlosData Engineer
DiegoData Engineer

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

### SQL Question 6: Calculate the Click-Through Rates for Cirrus Logic's Products

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).

1101150007
2102120007
3103130007
4101160008
5102110008
6103150008
##### Example Input:
1120107/01/2022
2120207/02/2022
3220307/03/2022
4220407/04/2022
5320507/05/2022
6320607/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:

### SQL Question 7: Why are stored procedures useful for analysts?

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:

### SQL Question 8: Find Sales Quantity and Total Sales Amount

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.

##### Example Input:
product_idproduct_nameproduct_price
101Product A100
102Product B200
103Product C300
104Product D400
105Product E500
##### Example Input:

|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:

### SQL Question 9: Calculating the Energy Usage

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.

### SQL Question 10: How does the constraint function, and in what scenarios might it be useful?

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:

### Preparing For The Cirrus Logic SQL Interview

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.

### Cirrus Logic Data Science Interview Tips

#### What Do Cirrus Logic Data Science Interviews Cover?

In addition to SQL interview questions, the other question categories tested in the Cirrus Logic Data Science Interview are:

#### How To Prepare for Cirrus Logic Data Science Interviews?

To prepare for Cirrus Logic Data Science interviews read the book Ace the Data Science Interview because it's got: