Data Analyst Interview Questions & Answers: Set 1, E-commerce Fundamentals
100 interview questions with model answers for freshers, set in E-commerce Fundamentals: SQL, Excel, statistics, Python, Power BI, business cases, AI and behavioral.
100 interview questions with model answers for freshers, set in Hospital & Healthcare: SQL, Excel, statistics, Python, Power BI, business cases, AI and behavioral.
Free with login: questions 1 and 2 are open to everyone, all 100 after you log in.
2 of 100 questions shown · Set 7 of 20 · Hospital & Healthcare
1.Find the average length of stay per department for patients admitted this year.
Answer: Length of stay (LOS) is discharge date minus admission date, averaged per department. I assume admissions(admission_id, patient_id, department_id, admit_date, discharge_date) and departments(department_id, department_name). I filter to admissions this year and only count discharged patients, because current inpatients have no discharge date yet and would distort the average. Subtracting two DATE values in PostgreSQL gives whole days; with timestamps you would use EXTRACT(EPOCH ...) / 86400.
SELECT d.department_name,
COUNT(*) AS admissions,
ROUND(AVG(a.discharge_date - a.admit_date), 1) AS avg_los_days
FROM admissions a
JOIN departments d ON d.department_id = a.department_id
WHERE a.admit_date >= DATE_TRUNC('year', CURRENT_DATE)
AND a.discharge_date IS NOT NULL
GROUP BY d.department_name
ORDER BY avg_los_days DESC;2.Find patients readmitted within 30 days of discharge.
Answer: A readmission is a new admission for the same patient within 30 days after a previous discharge. The cleanest way is LEAD() to get each patient's next admission date, then compare it with the current discharge date. Table: admissions(admission_id, patient_id, admit_date, discharge_date). In real reporting you would usually exclude planned readmissions (e.g. scheduled chemotherapy) and transfers, so agree the definition with clinicians first.
WITH ordered AS (
SELECT patient_id, admission_id, admit_date, discharge_date,
LEAD(admit_date) OVER (PARTITION BY patient_id
ORDER BY admit_date) AS next_admit
FROM admissions
)
SELECT patient_id, admission_id, discharge_date, next_admit,
next_admit - discharge_date AS days_to_readmit
FROM ordered
WHERE next_admit IS NOT NULL
AND next_admit - discharge_date BETWEEN 0 AND 30;Loading all 100 questions…
100 interview questions with model answers for freshers, set in E-commerce Fundamentals: SQL, Excel, statistics, Python, Power BI, business cases, AI and behavioral.
100 interview questions with model answers for freshers, set in Retail & Supermarket Chain: SQL, Excel, statistics, Python, Power BI, business cases, AI and behavioral.
100 interview questions with model answers for freshers, set in Mobile Banking & Fintech: SQL, Excel, statistics, Python, Power BI, business cases, AI and behavioral.