PART 1: SQL BASICS – Understand the Core Building Blocks
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 Concept What It Means
Table Like an Excel sheet (rows & columns)
Row A single record (one entry)
Column A field (e.g., name, age, date)
Primary Key Unique ID for each row
Foreign Key Links to another table’s key
Basic SQL Syntax Examples:
sql
CopyEdit
-- Create a table
CREATE TABLE students (
id INT PRIMARY KEY,
name VARCHAR(100),
age INT
);
-- Insert data
INSERT INTO students (id, name, age) VALUES (1, 'Rakshith', 22);
-- Read data
SELECT * FROM students;
-- Update data
UPDATE students SET age = 23 WHERE id = 1;
-- Delete data
DELETE FROM students WHERE id = 1;
PART 2: FREQUENTLY ASKED INTERVIEW QUESTIONS (Basic to Mid-Level)
Q1: What is the difference between WHERE and HAVING?
Answer:
• WHERE filters rows before grouping
• HAVING filters groups after aggregation
sql
CopyEdit
-- WHERE Example
SELECT * FROM students WHERE age > 20;
-- 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:
JOIN Type Result
INNER JOIN Returns only matching records in both tables
LEFT JOIN Returns all records from the left table + matching records from right
sql
CopyEdit
-- Example
SELECT a.name, b.course
FROM students a
LEFT JOIN enrollments b ON a.id = b.student_id;
Q3: What is a Primary Key vs Foreign Key?
Primary Key: Uniquely identifies each record in a table
Foreign Key: Links to a Primary Key in another table (for relational integrity)
Q4: What are aggregate functions in SQL?
Used to perform calculations on multiple rows:
Function Use
COUNT() Number of rows
SUM() Total of a numeric column
AVG() Average value
MAX() Highest value
Function Use
MIN() Lowest value
sql
CopyEdit
SELECT AVG(age) FROM students;
Q5: How do you find duplicate records?
sql
CopyEdit
SELECT name, COUNT(*)
FROM students
GROUP BY name
HAVING COUNT(*) > 1;
Q6: What is a subquery?
A query inside another query (nested query):
sql
CopyEdit
SELECT name
FROM students
WHERE id IN (SELECT student_id FROM enrollments WHERE course = 'SQL');
Q7: What are indexes and why are they used?
Indexes speed up searching in large tables — like an index in a book.
sql
CopyEdit
CREATE INDEX idx_name ON students(name);
PART 3: ADVANCED & PRACTICAL USES
Q8: How would you retrieve the 2nd highest salary from a table?
sql
CopyEdit
SELECT MAX(salary)
FROM employees
WHERE salary < (SELECT MAX(salary) FROM employees);
Q9: What is normalization?
Process of organizing data to avoid redundancy and maintain integrity.
Normal Form Meaning
1NF Atomic values only (no repeating groups)
2NF All non-key columns depend on full key
3NF No transitive dependency
Q10: What are transactions in SQL?
Set of SQL commands that are treated as a single unit.
sql
CopyEdit
BEGIN TRANSACTION;
UPDATE accounts SET balance = balance - 500 WHERE id = 1;
UPDATE accounts SET balance = balance + 500 WHERE id = 2;
COMMIT;
How to Practice SQL (Hands-On)
1. Use https://sqlfiddle.com/ (No installation needed)
2. Install DB Browser for SQLite or use MySQL Workbench
3. Create tables, insert mock data, try the queries
4. Practice with real scenarios like:
o Track student enrollments
o Employee database
o Sensor data logs (simulate GE Healthcare use)
Pro Interview Tips
• Don’t memorize — understand how to think with data
• Show how you'd write queries and optimize them
• Know when to use JOINs vs Subqueries
• Talk about data integrity, accuracy, and performance
SQL Scenario-Based Questions & System Design (Real-World + Interview Style)
Scenario 1: Design a Database for a Hospital Patient Management System
Tables You Might Create:
Table Name Fields
patients patient_id, name, age, gender, contact, address
doctors doctor_id, name, specialization, contact, dept_id
appointments appointment_id, patient_id, doctor_id, date, status
departments dept_id, dept_name, floor
diagnosis diagnosis_id, patient_id, disease, notes, date
medications med_id, diagnosis_id, medicine_name, dosage
Table Relationships:
• patients ⟶ appointments (1-to-many)
• doctors ⟶ appointments (1-to-many)
• appointments ⟶ diagnosis (1-to-1 or 1-to-many)
• diagnosis ⟶ medications (1-to-many)
• doctors ⟶ departments (many-to-1)
Interview Q: How would you retrieve all appointments for a patient named "Rakshith"?
sql
CopyEdit
SELECT a.date, d.name AS doctor, a.status
FROM appointments a
JOIN patients p ON a.patient_id = p.patient_id
JOIN doctors d ON a.doctor_id = d.doctor_id
WHERE p.name = 'Rakshith';
Q: How would you get all doctors working in 'Cardiology'?
sql
CopyEdit
SELECT d.name
FROM doctors d
JOIN departments dept ON d.dept_id = dept.dept_id
WHERE dept.dept_name = 'Cardiology';
Q: How would you find patients diagnosed with 'Diabetes'?
sql
CopyEdit
SELECT p.name, dg.notes
FROM diagnosis dg
JOIN patients p ON dg.patient_id = p.patient_id
WHERE dg.disease = 'Diabetes';
Scenario 2: Blood Bank Management System (Like your Internship Project)
Tables:
Table Name Fields
donors donor_id, name, blood_group, contact, last_donation
blood_stock blood_id, blood_group, units_available, last_updated
requests request_id, patient_name, blood_group, units, status
hospitals hospital_id, name, location, contact
Relationships:
• donors update → blood_stock increases
• requests by hospital → blood_stock decreases
Q: Find total units available of 'O+' blood group:
sql
CopyEdit
SELECT units_available
FROM blood_stock
WHERE blood_group = 'O+';
Q: Get names of donors who haven't donated in 6 months:
sql
CopyEdit
SELECT name
FROM donors
WHERE last_donation < DATE_SUB(CURDATE(), INTERVAL 6 MONTH);
Q: List pending blood requests from hospitals in 'Bengaluru':
sql
CopyEdit
SELECT r.patient_name, r.blood_group, h.name AS hospital
FROM requests r
JOIN hospitals h ON r.hospital_id = h.hospital_id
WHERE h.location = 'Bengaluru' AND r.status = 'Pending';
Scenario 3: Sensor Data Logging (Relates to Your Safety Jacket Project)
Tables:
Table Name Fields
devices device_id, location, status
sensor_data data_id, device_id, timestamp, sensor_type, value
alerts alert_id, data_id, alert_type, triggered_at, status
Q: How would you fetch all gas readings > 50 ppm?
sql
CopyEdit
SELECT timestamp, value
FROM sensor_data
WHERE sensor_type = 'Gas' AND value > 50;
Q: Get all alerts triggered for device in “Mine-Sector-3”
sql
CopyEdit
SELECT a.alert_type, a.triggered_at
FROM alerts a
JOIN sensor_data s ON a.data_id = s.data_id
JOIN devices d ON s.device_id = d.device_id
WHERE d.location = 'Mine-Sector-3';
Pro Interview Tip:
Whenever asked scenario-based SQL questions:
• First define the tables and relationships
• Then explain your thinking and structure
• Finally write the query if asked, or explain how you'd write it
SQL Mini Tasks & Mock Query Round
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.
Task 1: Retrieve Data Based on a Condition
You have a table called employees with:
• emp_id, name, department, salary
Question:
Get names of employees from the “Quality” department earning more than ₹30,000.
Expected Query:
sql
CopyEdit
SELECT name
FROM employees
WHERE department = 'Quality' AND salary > 30000;
Why it’s asked:
Tests filtering logic with multiple conditions using AND.
Task 2: Use Aggregate Function
Table: orders
• order_id, customer_id, amount
Question:
Find the total revenue generated from all orders.
Expected Query:
sql
CopyEdit
SELECT SUM(amount) AS total_revenue FROM orders;
Why it’s asked:
Tests your knowledge of aggregate functions.
Task 3: JOIN Two Tables
Tables:
• students(student_id, name)
• marks(student_id, subject, score)
Question:
Get student names with their subject and score.
Expected Query:
sql
CopyEdit
SELECT s.name, m.subject, m.score
FROM students s
JOIN marks m ON s.student_id = m.student_id;
Why it’s asked:
Tests INNER JOIN, understanding of primary/foreign keys.
Task 4: Grouping + Filtering
Table: blood_donors
• donor_id, blood_group, city
Question:
Show number of donors in each city, only if that city has more than 3 donors.
Expected Query:
sql
CopyEdit
SELECT city, COUNT(*) AS donor_count
FROM blood_donors
GROUP BY city
HAVING COUNT(*) > 3;
Why it’s asked:
Tests GROUP BY + HAVING (very common in interviews!)
Task 5: Subquery (Nested)
Table: patients(patient_id, name, age)
Question:
Get the names of patients older than the average age.
Expected Query:
sql
CopyEdit
SELECT name
FROM patients
WHERE age > (SELECT AVG(age) FROM patients);
Why it’s asked:
Tests use of subqueries inside WHERE.
Task 6: Top N Records
Table: engineers(name, experience_years)
Question:
Get the top 3 most experienced engineers.
Query (MySQL syntax):
sql
CopyEdit
SELECT name
FROM engineers
ORDER BY experience_years DESC
LIMIT 3;
Tip: Use LIMIT in MySQL/Postgres, TOP in SQL Server.
Want to Try Some on Your Own?
Here are 3 self-attempt questions you can try and ping me back with your answer (I’ll correct/help if needed):
Task 7:
Table: inventory(item_id, item_name, quantity, price)
Question:
Find the total value (quantity × price) of each item.
Task 8:
Table: attendance(emp_id, date, status)
Statuses = 'Present', 'Absent'
Question:
Find how many days each employee was present.
Task 9:
Table: feedback(user_id, rating) (rating is 1–5)
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:
• Where it came from
• When and how it was made
• Which supplier or batch it belonged to
• Which customers received it
Why it’s important in GE HealthCare:
• Helps quickly isolate and fix issues
• Ensures regulatory compliance (like FDA/ISO)
• Supports root cause analysis
• Prevents mass product recalls by narrowing down to faulty batches
Real Example:
If a sensor in a patient monitor fails, traceability helps you find:
• The supplier of the sensor
• The batch number of the components
• The manufacturing line and date
• All the devices built using the same sensor
2. What is a Non-Conformance Report (NCR)?
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.).
When is NCR raised?
• A part doesn’t meet specifications
• A supplier delivers defective items
• A process deviation is observed during audit
• Incorrect or missing documentation is found
What an NCR includes:
Field Description
Date When issue was found
Non-conformance Type Material, process, documentation, etc.
Field Description
Description What went wrong and how it was discovered
Part/Batch Info Item number, lot number, supplier, etc.
Immediate Action Containment — stop use, quarantine parts
Disposition Rework, reject, scrap, return, etc.
Root Cause Found through RCA/5 Whys
CAPA Reference If corrective action was taken
Why NCR is important in GE:
• Documents and tracks quality issues
• Enables transparency and accountability
• Provides a base for RCA & CAPA implementation
• Required for audit trails by regulatory bodies
Interview Style Summary:
“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.”