At Credo Technology, SQL is typically used for analyzing customer data to optimize marketing strategies, and managing product databases to streamline operational efficiency. That's why Credo Technology often tests SQL coding questions in interviews for Data Analyst, Data Science, and BI jobs.
To help you prepare for the Credo Technology SQL interview, here’s 9 Credo Technology SQL interview questions – able to solve them?
Credo Technology is an E-commerce tech company that sells a wide variety of technology products. The database tables are standardized to have a table and an table, among other tables.
We consider a power, VIP, or whale user to be a customer who has made more orders than 95% of other customers in the most recent month. These power customers are very important to the business as they contribute a substantial portion of the overall sales.
Please write a SQL query to analyze the customer database, and identify these power users based on their ordering activity.
customer_id | first_name | last_name |
---|---|---|
101 | John | Doe |
102 | Jane | Doe |
103 | Alice | Johnson |
104 | Bob | Johnson |
105 | Charlie | Lee |
order_id | customer_id | order_date | product_id | order_amount |
---|---|---|---|---|
1231 | 101 | 06/18/2022 | 20501 | 100 |
1432 | 101 | 06/21/2022 | 39852 | 200 |
3234 | 103 | 07/24/2022 | 20501 | 150 |
5423 | 104 | 07/24/2022 | 39852 | 300 |
6345 | 105 | 07/05/2022 | 20501 | 120 |
7452 | 102 | 07/08/2022 | 39852 | 230 |
8522 | 101 | 07/18/2022 | 20501 | 100 |
9636 | 101 | 07/26/2022 | 39852 | 200 |
We calculate the number of orders for each customer in the current month using a statement, and then calculate the 95th percentile of the order counts. The output of the query provides details of customers whose order count is greater than the 95th percentile order count, indicating that these are our 'VIP' customers.
To work on another SQL customer analytics question where you can solve it interactively and have your SQL code instantly graded, try this Walmart Labs SQL Interview Question:
Let's say Credo Technology's HR department wants to analyze the employees' salaries. They want to know each employee's rank within their department according to their salary. Candidates would write a query to rank employees within each department based on their salaries in a descending order. If two or more employees have the same salary, they should have the same rank and the next person should have a rank incremented by the number of people having the same salary.
Please assume an table that has , , and columns.
employee_id | name | department | salary |
---|---|---|---|
1 | John | HR | 8000 |
2 | Samantha | HR | 8000 |
3 | Jacob | HR | 7500 |
4 | Lucy | Operations | 6000 |
5 | Mike | Operations | 6500 |
6 | Eddy | Operations | 6000 |
7 | Sarah | Sales | 7000 |
8 | Chris | Sales | 8000 |
9 | Bob | Sales | 8000 |
This query uses a window function to rank the employees within each department based on their salary. The clause divides the rows into different partitions (in this case, 'department') and the clause specifies the order of the rows in each partition (in this case, 'salary DESC'). The function doesn't skip any rank (leaves no gaps) when assigning a rank to the rows, meaning that if the highest salary (rank 1) is earned by more than one employee in a department, the next salary will be ranked as 2 and so on.
p.s. Window functions show up pretty frequently during SQL interviews, so practice the 27+ window function questions on DataLemur
In SQL, a join is used to combine rows from different tables based on a shared key or set of keys, resulting in a single merged table of data.
There are four distinct types of JOINs: , , , and .
(INNER) JOIN: Retrieves records that have matching values in both tables involved in the join.
LEFT (OUTER) JOIN: Retrieves all the records/rows from the left and the matched records/rows from the right table.
RIGHT (OUTER) JOIN: Retrieves all the records/rows from the right and the matched records/rows from the left table.
FULL (OUTER) JOIN: Retrieves all the records where there is a match in either the left or right table.
Credo Technology utilizes SQL for tracking their product sales and customer preferences. Assume that the company offers several technology products under different categories. They are interested in knowing which products are frequently bought together, and which product categories are preferred by the customers the most. They have two tables: and .
The table has the following columns:
The table has the following columns:
Design a SQL query that identifies the top 3 most frequently bought together products and the top 3 preferred product categories in terms of sales.
sales_id | customer_id | product_id | sale_date |
---|---|---|---|
5672 | 265 | 123 | 06/08/2022 |
7621 | 364 | 354 | 06/10/2022 |
5589 | 192 | 786 | 07/26/2022 |
7812 | 265 | 123 | 06/18/2022 |
7102 | 259 | 786 | 07/05/2022 |
product_id | product_name | category_id |
---|---|---|
123 | iphone 12 | 1 |
354 | rechargeable batteries | 2 |
786 | Roomba 675 | 3 |
To find the most frequently bought together products:
To find the top 3 preferred product categories in terms of sales:
The first query joins the sales table with itself on customer_id to get pairs of products bought by the same customer, and then groups by product pair, counts the occurrences and gets top 3 pairs.
The second query joins the sales and products tables on product_id, groups by category_id, counts the occurrences of each category in sales, and then gets the top 3 categories.
No, in 99% of normal cases a and do NOT produce the same result.
You can think of more as set addition when it combines the results of two tables.
You can think of a more as set multiplication, producing all combos of table 1 with combos of table 2.
You are given a database of customer records for Credo Technology. The task is to find all customers who are part of the company's "Elite" program. Customers are identified as being a part of the Elite program if their 'customer_description' includes the string "ELITE".
customer_id | first_name | last_name | customer_description | |
---|---|---|---|---|
1 | John | Doe | john.doe@credo.com | Regular,Mainlanders |
2 | Jane | Smith | jane.smith@credo.com | Elite,Senior |
3 | Bob | Brown | bob.brown@credo.com | Regular,SMME |
4 | Alice | Johnson | alice.johnson@credo.com | Elite,Professional |
customer_id | first_name | last_name | |
---|---|---|---|
2 | Jane | Smith | jane.smith@credo.com |
4 | Alice | Johnson | alice.johnson@credo.com |
You can use the keyword in SQL to match a specific pattern in a string. The symbol is used as a wildcard to match any sequence of characters. Here is the PostgreSQL query that solves the problem:
This query selects the customer_id, first_name, last_name, and email from the customers table where the customer_description contains the string "Elite". The '%' symbol is used as a wildcard to match any number of characters before or after "Elite".
This would return all customers who are part of the "Elite" program.
A database index is a way to optimize the performance of a database by reducing the amount of data that needs to be searched to retrieve a record.
There are several types of indexes that can be used in a database:
For a concrete example, say you had a table of Credo Technology customer payments with the following columns: payment_id, customer_id, payment_amount, and payment_date.
Here's what a clustered index on the column would look like:
A clustered index on the column would determine the physical order of the records in the table based on the . This means that the records with the earliest values would be stored together physically in the table, followed by records with later payment_date values.
Having a clustered index on the column can speed up queries that filter or sort the data based on the payment_date, as the records are already physically sorted in the table. For example, if you want to retrieve all the payments made in the month of January, the database can use the clustered index to quickly locate and retrieve the desired records without having to search through the entire table.
You've been given two tables and . The table lists all the customers of Credo Technology while the table captures all the orders placed by these customers, including the product and the order amount. Your task is to write a SQL query to calculate the average order amount spent by each customer for a specific product 'Product-1'.
customer_id | first_name | last_name |
---|---|---|
123 | John | Doe |
456 | Jane | Smith |
789 | Tom | Cruise |
112 | Emma | Stone |
order_id | customer_id | product | order_amount |
---|---|---|---|
50001 | 123 | Product-1 | 120 |
69852 | 456 | Product-2 | 500 |
50002 | 123 | Product-1 | 180 |
69853 | 789 | Product-3 | 250 |
50003 | 123 | Product-1 | 100 |
69853 | 112 | Product-2 | 200 |
This query uses a clause to combine the and tables on the column. It then uses to filter out the orders for 'Product-1'. The clause groups the results by , , and . The function is used on to find the average.
customer_id | first_name | last_name | avg_order_amount |
---|---|---|---|
123 | John | Doe | 133.33 |
Here, we can see that the customer 'John Doe' with ID 123 has an average order amount of 133.33 for 'Product-1'.
Because join questions come up frequently during SQL interviews, take a stab at this SQL join question from Spotify:
Credo Technology is a company that sells various software products. Each product has its own unique . Every time a product is sold, an order is created in the system with a , , and .
As a data analyst in Credo Technology, you are asked to calculate the monthly revenue for each product. Monthly revenue is defined as the total amount of sales per product for each month. The month of each sale should be extracted from . Create a query that will return the results in the order of months and then by the products that made the highest revenue first.
order_id | product_id | sale_date | sale_price |
---|---|---|---|
101 | 200 | 2022-01-15 | 100 |
102 | 300 | 2022-01-20 | 200 |
103 | 200 | 2022-02-10 | 150 |
104 | 400 | 2022-02-25 | 300 |
105 | 300 | 2022-02-28 | 200 |
106 | 200 | 2022-03-01 | 100 |
107 | 400 | 2022-03-10 | 200 |
108 | 300 | 2022-03-20 | 150 |
109 | 200 | 2022-04-01 | 200 |
110 | 300 | 2022-04-15 | 250 |
month | product | revenue |
---|---|---|
1 | 300 | 200 |
1 | 200 | 100 |
2 | 400 | 300 |
2 | 300 | 200 |
2 | 200 | 150 |
3 | 300 | 150 |
3 | 400 | 200 |
3 | 200 | 100 |
4 | 300 | 250 |
4 | 200 | 200 |
In this query, is used to get the month part of the date in column. Sum of per month per product is calculated using . This is done within each group of same month and product which is specified by the clause. The results are ordered by month first and then by revenue in descending order with .
Assuming that you've already got basic SQL skills, the next best tip we have to prepare for the Credo Technology SQL interview is to solve as many practice SQL interview questions as you can! Beyond just solving the above Credo Technology SQL interview questions, you should also solve the 200+ SQL questions on DataLemur which come from companies like Facebook, Google and unicorn tech startups.
Each problem on DataLemur has hints to guide you, fully explained answers along with a discussion board to see how others solved it and crucially, there's an interactive SQL code editor so you can easily right in the browser your SQL query and have it graded.
To prep for the Credo Technology SQL interview you can also be a great idea to solve interview questions from other tech companies like:
In case your SQL query skills are weak, don't worry about diving straight into solving questions – improve your SQL foundations with this free SQL for Data Analytics course.
This tutorial covers topics including creating pairs via SELF-JOINs and CASE/WHEN/ELSE statements – both of which come up often during Credo Technology SQL assessments.
In addition to SQL query questions, the other topics to practice for the Credo Technology Data Science Interview are:
To prepare for Credo Technology Data Science interviews read the book Ace the Data Science Interview because it's got: