sql
sql
What is SQL?
SQL (Structured Query Language) is used to store, retrieve, update, and manage data in relational databases (like MySQL, PostgreSQL,
Oracle, SQLite).
Key Concepts:
sql
CopyEdit
-- Create a table
name VARCHAR(100),
age INT
);
-- Insert data
INSERT INTO students (id, name, age) VALUES (1, 'Rakshith', 22);
-- Read data
-- Update data
-- Delete data
Answer:
sql
CopyEdit
-- WHERE Example
-- HAVING Example
SELECT age, COUNT(*) FROM students GROUP BY age HAVING COUNT(*) > 2;
Q2: What is the difference between INNER JOIN and LEFT JOIN?
Answer:
LEFT JOIN Returns all records from the left table + matching records from right
sql
CopyEdit
-- Example
FROM students a
Function Use
sql
CopyEdit
sql
CopyEdit
FROM students
GROUP BY name
sql
CopyEdit
SELECT name
FROM students
sql
CopyEdit
Q8: How would you retrieve the 2nd highest salary from a table?
sql
CopyEdit
SELECT MAX(salary)
FROM employees
sql
CopyEdit
BEGIN TRANSACTION;
COMMIT;
o Employee database
Table Relationships:
Interview Q: How would you retrieve all appointments for a patient named "Rakshith"?
sql
CopyEdit
FROM appointments a
sql
CopyEdit
SELECT d.name
FROM doctors d
sql
CopyEdit
FROM diagnosis dg
Tables:
Relationships:
sql
CopyEdit
SELECT units_available
FROM blood_stock
sql
CopyEdit
SELECT name
FROM donors
sql
CopyEdit
FROM requests r
Tables:
sql
CopyEdit
FROM sensor_data
sql
CopyEdit
FROM alerts a
Instructions:
Each task mimics real-life use. After reading the task, try to mentally structure the query. I’ll then give you the solution + bonus
explanation.
Question:
Get names of employees from the “Quality” department earning more than ₹30,000.
Expected Query:
sql
CopyEdit
SELECT name
FROM employees
Table: orders
Question:
Find the total revenue generated from all orders.
Expected Query:
sql
CopyEdit
Tables:
• students(student_id, name)
Question:
Get student names with their subject and score.
Expected Query:
sql
CopyEdit
FROM students s
Table: blood_donors
Question:
Show number of donors in each city, only if that city has more than 3 donors.
Expected Query:
sql
CopyEdit
FROM blood_donors
GROUP BY city
Expected Query:
sql
CopyEdit
SELECT name
FROM patients
Question:
Get the top 3 most experienced engineers.
sql
CopyEdit
SELECT name
FROM engineers
LIMIT 3;
Here are 3 self-attempt questions you can try and ping me back with your answer (I’ll correct/help if needed):
Task 7:
Question:
Find the total value (quantity × price) of each item.
Task 8:
Question:
Find how many days each employee was present.
Task 9:
Question:
Get average rating given by each user.
1. What is Traceability?
Definition:
Traceability is the ability to track the history, location, and movement of a product or component throughout its lifecycle — from raw
material to delivery and even service.
In simpler terms:
If something fails, traceability helps you trace back:
Real Example:
Definition:
A Non-Conformance Report (NCR) is a formal record raised when a product, part, process, or supplier does not meet required standards
(quality, design, safety, etc.).
Field Description
“Traceability ensures that every component, process, and product can be traced backward and forward through the supply chain. This
helps in effective root cause analysis, batch recalls, and process validation.”
“When a product or process deviates from expected quality standards, a Non-Conformance Report (NCR) is raised. It formally
documents the issue, its scope, containment actions, and leads to RCA and CAPA if needed.”