2 views
23 Jan 2026
You have ProductsStage(product_id, name, price). Update existing Products and insert new ones in one MERGE statement....
2 views
23 Jan 2026
Insert a customer with id=101, name='Amit', city='Pune'....
3 views
23 Jan 2026
Insert 3 departments in one statement....
3 views
23 Jan 2026
Update customer city to 'Delhi' where customer_id=101....
2 views
23 Jan 2026
Delete orders where status='CANCELLED' and the order_date is older than 90 days from today....
3 views
23 Jan 2026
Create a backup table OrdersBackup and copy only last month's orders into it (full rows)....
2 views
23 Jan 2026
Give 10% hike to Employees in department 'Tech'. Departments table has dept_name....
3 views
23 Jan 2026
In LoginLogs(user_id, logged_at, ip_address), remove duplicates where same user_id and ip_address appear multiple times on same day; keep the latest logged_at....
2 views
23 Jan 2026
If an order exists update its status, otherwise insert it. Write an upsert pattern....
2 views
23 Jan 2026
Place an order and its order items together. If item insert fails, order should not be created....
2 views
23 Jan 2026
Give a 5% discount on Products that have not sold in the last 180 days. Use Orders + OrderItems to find what sold recently....
3 views
23 Jan 2026
Instead of deleting customers, keep the row and mark it inactive. Add is_active (default 1) and set is_active=0 for customers who have no orders in the last 2 years....
2 views
23 Jan 2026
In Employees, if salary is null set to 25000, if salary < 15000 set to 15000, else keep as is. Write one update statement....
2 views
23 Jan 2026
Delete orders that have no order items (orphan orders)....
2 views
23 Jan 2026
You loaded ProductsStage. Insert only valid rows (price>0 and name not null) into Products....