2 views
23 Jan 2026
You have a table StudentContacts(student_id, name, phones) where phones stores values like '9999,8888'. Convert it to 1NF by designing tables and writing SQL DDL....
2 views
23 Jan 2026
Table Marks(student_id, subject_id, student_name, subject_name, marks) with PK(student_id, subject_id). Explain what is wrong and show a 2NF decomposition using SQL tables....
2 views
23 Jan 2026
Employees(emp_id, emp_name, dept_id, dept_name). Show 3NF decomposition....
2 views
23 Jan 2026
Table Booking(pnr, passport_no, email). Any one of these can uniquely identify a booking. Write SQL to enforce this with UNIQUE constraints....
4 views
23 Jan 2026
Given a table OrdersRaw(order_id, items, quantities) where items are stored like '10|12|14' and quantities '1|2|1', explain why it breaks 1NF in description and give normalized tables in SQL....
3 views
23 Jan 2026
CustomerProfile(customer_id, name, city, state, state_code). state_code depends on state. Show 3NF tables....
2 views
23 Jan 2026
You have Movie(movie_id, title, actor_names) as a comma list. Convert to normalized design....
3 views
23 Jan 2026
Table Teaching(teacher, subject, room). Rule: each subject is taught in exactly one room, but a teacher can teach many subjects. Show BCNF decomposition in SQL....
2 views
23 Jan 2026
Table ProductSupply(product_id, supplier_name, supplier_phone, supply_price). Decompose to reduce update anomaly....
2 views
23 Jan 2026
Table Employees(emp_id, name, address) where address stores 'house,street,city'. Normalize it into separate columns and keep it 1NF....
2 views
23 Jan 2026
You need employee salary history. Design normalized tables to store salary changes with effective_from date....
3 views
23 Jan 2026
Table Shipment(order_id, courier, courier_phone). courier determines courier_phone. Show normalized tables....
2 views
23 Jan 2026
In raw InvoiceRaw(invoice_id, customer_name, customer_city, line_items). Show a normalized design that allows storing customer even without invoices....
2 views
23 Jan 2026
OrdersReport(order_id, customer_city, product_category, qty, amount). Explain in description that this is a report table and show base normalized tables in SQL....
3 views
23 Jan 2026
Create a stored procedure sp_add_department(p_id, p_name) that inserts into Departments....
3 views
23 Jan 2026
Create procedure sp_hike_salary(p_emp_id, p_percent) that increases salary for that employee....
3 views
23 Jan 2026
Create sp_order_total(p_order_id, OUT p_total) that returns sum(qty*price) from OrderItems....
3 views
23 Jan 2026
Create sp_delete_old_logs(p_days) that deletes from LoginLogs older than p_days....
3 views
23 Jan 2026
Show how to call sp_order_total for order 7001....
4 views
23 Jan 2026
Create sp_transfer_funds(p_from, p_to, p_amt) to transfer money between two accounts. If the sender does not have enough balance, rollback the transaction so nothing changes....
2 views
23 Jan 2026
Create sp_mark_low_stock(p_limit) that sets Products.low_stock=1 when qty_on_hand < p_limit....
2 views
23 Jan 2026
Create sp_top_customers(p_n) that returns top N customers by total spend....
4 views
23 Jan 2026
Create sp_add_coupon(code, discount) that validates discount first. If discount is not in 1..80, raise an error; otherwise insert the coupon....
2 views
23 Jan 2026
Create sp_refresh_daily_sales that truncates DailySales and re-inserts aggregated totals from Orders....
5 views
23 Jan 2026
Make sp_add_department safe if dept_id already exists: update name instead of failing....
2 views
23 Jan 2026
Create sp_discount_category(p_category, p_percent) that updates product prices and writes an audit row per product into PriceAudit(product_id, old_price, new_price, changed_at)....
3 views
23 Jan 2026
Create sp_find_duplicate_emails that returns emails appearing more than once in Users....
2 views
23 Jan 2026
When inserting into Payments, deadlock may happen. Write a stored procedure outline that retries 3 times (simple loop)....
3 views
23 Jan 2026
Find employees whose salary is above the company average salary....
2 views
23 Jan 2026
List customers who have placed at least one order....
2 views
23 Jan 2026
Find products that have at least one order item....
2 views
23 Jan 2026
Get department-wise average salary, then list departments where avg salary > 50000....
2 views
23 Jan 2026
List employees who earn more than the average salary of their own department....
3 views
23 Jan 2026
Return orders that are the latest order for each customer....
3 views
23 Jan 2026
Return the second highest distinct salary from Employees....
2 views
23 Jan 2026
Write a query using subquery that returns customers who placed more than 3 orders....
3 views
23 Jan 2026
Find customers who did not place any order. Use NOT EXISTS (safer than NOT IN)....
3 views
23 Jan 2026
Update Employees set salary to department average salary for employees who have salary NULL....
4 views
23 Jan 2026
Return products where price is greater than average price of their category....
3 views
23 Jan 2026
Payments(order_id, due_date, paid_at). Find customers where for every payment, paid_at > due_date....
2 views
23 Jan 2026
Delete Products that were created more than 365 days ago and never appeared in OrderItems. Use NOT EXISTS to avoid NULL issues....
2 views
23 Jan 2026
Find the product category with the highest revenue. Revenue = SUM(qty * price) from OrderItems joined with Products....
3 views
23 Jan 2026
You are inserting an order and items. If one item insert fails, rollback only item inserts but keep the order row. Use SAVEPOINT....
3 views
23 Jan 2026
Update status of an order and commit....
2 views
23 Jan 2026
You accidentally updated all employees salary. Rollback the transaction....
1 views
23 Jan 2026
Before deleting old logs, create a savepoint. If you feel too many rows got deleted, rollback to the savepoint; otherwise commit....
2 views
23 Jan 2026
Insert a customer and an order in one transaction....
2 views
23 Jan 2026
Show how to release a savepoint after you are sure you will not rollback to it....
2 views
23 Jan 2026
During a batch insert, you want to rollback only the last 100 rows if something goes wrong. Show the savepoint pattern....
2 views
23 Jan 2026
Write a simple script that turns autocommit off, runs two updates, then commits....
2 views
23 Jan 2026
Show a generic pattern: begin, do steps, if any step fails then rollback, else commit....
3 views
23 Jan 2026
You need to create a table and then insert rows. Write a script with commit. Mention in description that some DBs auto-commit DDL....
3 views
23 Jan 2026
In a long transaction you updated 3 tables. Rollback only the last table updates using savepoint....
5 views
23 Jan 2026
Before commit, run a validation query. If it returns rows, rollback. Show the idea in one script....
3 views
23 Jan 2026
Write a transaction script outline that retries after rollback (concept). Provide a simple loop-like pseudo SQL....
2 views
23 Jan 2026
You want to do: reserve stock, then charge payment. Show savepoint usage so payment failure restores stock....
2 views
23 Jan 2026
Transfer 500 from account 1 to account 2 using a transaction....
3 views
23 Jan 2026
Inside one transaction, read the same row twice. Show the basic idea using SELECT statements....
2 views
23 Jan 2026
Show that you should lock a row before updating by using SELECT ... FOR UPDATE....
2 views
23 Jan 2026
Set transaction isolation level to READ COMMITTED for a transaction....
2 views
23 Jan 2026
Two sessions update same row. Show a safe pattern using a version column and conditional update....
4 views
23 Jan 2026
Write a transaction that counts active orders, then inserts a new active order. Mention isolation needed in description and show SERIALIZABLE statement....
2 views
23 Jan 2026
While placing an order, keep a savepoint after reserving stock. If payment fails, rollback to savepoint....
2 views
23 Jan 2026
Two transactions lock resources in opposite order. Provide two scripts in sample_solution separated by a pipe symbol....
2 views
23 Jan 2026
When processing an order, lock it so two workers do not process it together. Write a safe SELECT FOR UPDATE pattern....
4 views
23 Jan 2026
Decrease Inventory.qty by requested amount only if enough stock. Make it atomic in one statement and run inside a transaction....
2 views
23 Jan 2026
Implement a safe job-queue pop: pick one NEW job, lock it so others can't pick it, mark it IN_PROGRESS, and return the picked job_id. Use FOR UPDATE SKIP LOCKED if available....
4 views
23 Jan 2026
Wallet(user_id, balance). Two payments at same time should not allow negative balance. Write a safe transaction with check....
3 views
23 Jan 2026
You need a consistent report while inserts keep happening in parallel. Start a transaction in REPEATABLE READ and run your report query inside it....
2 views
23 Jan 2026
Two doctors on call table. Each transaction sees at least one on call and turns itself off, resulting none on call. Use SERIALIZABLE to prevent....
0 views
23 Jan 2026
In Customers, automatically trim and lowercase email before insert....
0 views
23 Jan 2026
After inserting into Orders, insert a row into AuditLog(table_name, row_id, action)....
0 views
23 Jan 2026
Stop INSERT and UPDATE if Products.price ...
0 views
23 Jan 2026
On update of Orders, set updated_at to current timestamp automatically....
0 views
23 Jan 2026
When a new OrderItems row is inserted, decrement Inventory.qty....
0 views
23 Jan 2026
Block deleting an order if any payment exists for that order. Use a BEFORE DELETE trigger on Orders and check Payments....
0 views
23 Jan 2026
On Employees salary update, insert into SalaryAudit(emp_id, old_salary, new_salary, changed_at)....
0 views
23 Jan 2026
Customers(customer_id, code). On insert, if code is null, set it as 'C' + customer_id....
0 views
23 Jan 2026
Maintain DailySales(day, amount). After insert into Orders, update DailySales for that date....
0 views
23 Jan 2026
Coupons(code, is_active). Before INSERT, if the same code already exists with is_active=1, then block the insert....
0 views
23 Jan 2026
Before inserting OrderItems, ensure Inventory has enough qty for that product. If stock is not enough, raise an error to stop the insert....
0 views
23 Jan 2026
On update of OrderItems.qty, adjust Inventory by the difference....
0 views
23 Jan 2026
Before updating Employees.salary, block the update if the new salary is less than 80% of the old salary....
0 views
23 Jan 2026
Instead of physically deleting a customer, do a soft delete: set is_active=0 and stop the DELETE. Use a BEFORE DELETE trigger to enforce this rule....
0 views
23 Jan 2026
Create view v_customer_basic showing customer_id, name, city....
0 views
23 Jan 2026
Write a query that reads from v_customer_basic for city='Pune'....
0 views
23 Jan 2026
Create view v_active_products that filters Products where is_active=1....
0 views
23 Jan 2026
Update v_active_products to include category as well....
0 views
23 Jan 2026
Drop view v_customer_basic if it exists....
0 views
23 Jan 2026
Create v_order_summary showing order_id, customer_name, total_amount, order_date....
0 views
23 Jan 2026
Payroll(emp_id, salary, bank_account). Create view exposing emp_id and salary only....
0 views
23 Jan 2026
Create a view v_new_orders that selects Orders where status='NEW'. Show an update statement that updates through the view....
0 views
23 Jan 2026
Create view v_daily_sales that returns day and total_sales from Orders....
0 views
23 Jan 2026
Assume your database supports materialized views. Create one materialized view that stores monthly revenue from Orders....
0 views
23 Jan 2026
Create v_my_city_customers that only returns customers for city='Delhi'....
0 views
23 Jan 2026
Create view v_duplicate_emails that lists emails appearing more than once in Users....
0 views
23 Jan 2026
Create view v_customer_latest_order that shows each customer with their latest order_id and date....
0 views
23 Jan 2026
Create view v_category_revenue that returns category and revenue using OrderItems and Products....
3 views
23 Jan 2026
You want user support_viewer to see only customer_id and name from Customers, not email/phone. Grant SELECT on only these columns (column-level privilege)....
2 views
23 Jan 2026
Create a new table TopCustomers from Orders that stores customer_id and spend, then add a primary key on customer_id....
2 views
23 Jan 2026
You have ProductsStage(product_id, name, price). Update existing Products and insert new ones in one MERGE statement....
14 views
23 Jan 2026
Find customers who placed at least one order in 3 consecutive months (any year). Return customer_id only. Hint: convert to month buckets, then use a window row_number trick....
2 views
23 Jan 2026
Customers(dob). Return customer_id and age_years as integer (approx)....
2 views
23 Jan 2026
Create an index to speed up WHERE LOWER(name)=LOWER(?) on Customers....
4 views
23 Jan 2026
List employee pairs in the same department who have exactly the same salary (show both emp names)....
2 views
23 Jan 2026
You have StudentSkillLang(student_id, skill, language) where skills and languages are independent lists per student. Decompose to avoid mixed combinations....
2 views
23 Jan 2026
Create sp_place_order(p_customer_id, p_order_id) that inserts an order, then inserts all rows from TempOrderItems into OrderItems for that order in one go....
2 views
23 Jan 2026
Return customers for which there is no order with unpaid balance. Unpaid means Orders.total_amount > sum(Payments.amount)....
2 views
23 Jan 2026
You are fixing city names in Customers in batches. Show a pattern: create savepoint, run update for a batch, rollback to savepoint if something looks wrong, else continue and finally commit....
2 views
23 Jan 2026
While processing orders, sometimes you get stuck waiting on locks. Set a short lock timeout, pick one NEW order with a row lock, update it to PROCESSING, then commit....
0 views
23 Jan 2026
When a customer row is deleted, copy it into DeletedCustomers(customer_id, name, deleted_at) before deletion....
0 views
23 Jan 2026
Create view v_customer_spend_rank that shows customer_id, spend, and rank by spend (highest rank 1)....
5 views
23 Jan 2026
You have a table Employees(emp_id, name, dept_id, salary, hire_date). Make dept_id mandatory and set default salary as 30000 for new rows....
5 views
23 Jan 2026
Create table Users(user_id, email, phone). Ensure email is unique and not null....
5 views
23 Jan 2026
In table Reviews(review_id, rating, comment), rating must be between 1 and 5....
4 views
23 Jan 2026
Create Enrollment(student_id, course_id, enrolled_on). One student can enroll once per course. Make (student_id, course_id) the primary key....
8 views
23 Jan 2026
Create Departments(dept_id, dept_name) and Employees(emp_id, name, dept_id). Add FK so employee dept_id must exist in Departments....
7 views
23 Jan 2026
In Orders(order_id) and Payments(payment_id, order_id), enforce that an order cannot be deleted if it has payments....
6 views
23 Jan 2026
In Customers(customer_id) and Orders(order_id, customer_id), make it so when a customer is deleted, all their orders are deleted too....
3 views
23 Jan 2026
In Coupons(code, discount_percent, max_discount), discount_percent must be 0 to 80, and max_discount must be at least 100 if discount_percent > 50....
5 views
23 Jan 2026
In Users(email), you want emails to be unique even if case differs (A@x.com vs a@x.com). Write one practical approach using a stored generated column lower_email and a UNIQUE constraint on it....
4 views
23 Jan 2026
You are inserting parent and child rows in one transaction. Write a safe sequence so the FK does not fail when you insert child first....
3 views
23 Jan 2026
In Products(product_id, price), price should be > 0 but table has old bad data. Write a query to find all invalid rows before adding a CHECK constraint....
5 views
23 Jan 2026
In Seats(bus_id, seat_no, status), seat_no should be unique per bus only for active seats (status='ACTIVE'). Write a SQL approach that enforces it using a separate table ActiveSeats and FK/PK....
6 views
23 Jan 2026
You are loading Orders first, then Customers later. How will you prevent orphan customer_id in Orders? Write a staging-table approach....
4 views
23 Jan 2026
In table StudentMarks(student_id, exam_date, subject, marks), a student can have only one record per subject per exam_date. Add the right constraint....
7 views
23 Jan 2026
In Payments(payment_id, order_id, card_txn_id, upi_txn_id), a payment can be done either by card or by UPI. Enforce rule: exactly one of card_txn_id and upi_txn_id must be filled (not both, not none)....
2 views
23 Jan 2026
Create a user analyst and grant only SELECT on Orders table....
3 views
23 Jan 2026
User intern was given INSERT on Customers by mistake. Remove it....
2 views
23 Jan 2026
Create a role report_reader with SELECT on Customers and Orders, then grant the role to user rohit....
2 views
23 Jan 2026
Procedure sp_monthly_sales exists. Give user accountant permission to execute it....
2 views
23 Jan 2026
User analyst already exists. Write the SQL to check what privileges/grants are currently given to this user....
2 views
23 Jan 2026
Create user readonly_user, then give only SELECT access on all tables under schema sales_db. Keep it least-privilege (no insert/update/delete)....
2 views
23 Jan 2026
Give team_lead SELECT on Employees with grant option, then explain the risk in one line inside description....
2 views
23 Jan 2026
User rohit should no longer have role report_reader. Write the revoke statement....
2 views
23 Jan 2026
User data_entry should be able to SELECT and INSERT into Orders but cannot UPDATE or DELETE. Write grants....
2 views
23 Jan 2026
Create a view v_public_customers that exposes only customer_id and name. Then grant SELECT on the view to public_user without granting base table access....
2 views
23 Jan 2026
You want to allow SELECT on Payroll only through a view, not directly on the base table. Create a view that hides salary and bank_account, then grant SELECT on the view to user auditor....
3 views
23 Jan 2026
You are deactivating contractor_user. Revoke all granted permissions first, then lock/disable the account (write generic SQL steps)....
2 views
23 Jan 2026
User app_user should not query base tables directly but can call procedures sp_place_order and sp_pay_order. Write grants only for procedures....
2 views
23 Jan 2026
If a user owns objects and you want to drop the user, what should you do first? Write a safe sequence in SQL terms....
2 views
23 Jan 2026
Write SQL to create database shop_db and a Products table with id, name, price....
2 views
23 Jan 2026
Add column status to Orders table, default 'NEW'....
2 views
23 Jan 2026
In Customers table, rename column full_name to name....
2 views
23 Jan 2026
Drop table TempUpload if it exists....
2 views
23 Jan 2026
Create LoginLogs(log_id, user_id, logged_at default current timestamp, ip_address)....
2 views
23 Jan 2026
Create an index on Orders(order_date) to speed up date range filters....
4 views
23 Jan 2026
Departments exists. Employees exists without FK. Add FK on Employees.dept_id referencing Departments.dept_id....
2 views
23 Jan 2026
In Customers table, phone is stored as INT but you want to keep leading zeros and '+' sign. Change phone column to VARCHAR(20)....
2 views
23 Jan 2026
Create a view v_active_orders that shows only orders with status='ACTIVE'....
3 views
23 Jan 2026
In Products, price must be >= 1. Add a CHECK constraint....
2 views
23 Jan 2026
Some DBs cannot drop a column easily. Show a safe 3-step approach to remove column temp_flag from Orders....
2 views
23 Jan 2026
Add a column searchable_name in Customers that stores lower(name) for case-insensitive search, then index it....
3 views
23 Jan 2026
Orders table is huge. Create a monthly partitioned table outline for order_date....
3 views
23 Jan 2026
Create AuditLog(audit_id, table_name, row_id, action, changed_at)....
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....
3 views
23 Jan 2026
You have Customers(customer_id, name, city). Write a query to show only customer_id and name for customers living in 'Mumbai'. Keep it simple: one WHERE condition....
3 views
23 Jan 2026
From Orders(order_id, order_date), show the latest 10 orders. Sort by order_date (newest first). If dates are same, you can sort by order_id too....
2 views
23 Jan 2026
You need a small city-wise report. From Customers(city), return city and how many customers are in that city....
3 views
23 Jan 2026
From Employees and Departments, show only those departments where employee count is more than 5. Display dept_name and the count....
2 views
23 Jan 2026
From Orders(status), list all different statuses available. You should not repeat the same status in output....
2 views
23 Jan 2026
From Orders(customer_id, total_amount), find the customer who spent the most overall. First do SUM per customer, then pick the highest one....
2 views
23 Jan 2026
Make a simple daily sales report for the last 7 days. From Orders(order_date, total_amount), show order_date and total sales per day....
4 views
23 Jan 2026
List customers who never placed any order. You can solve using LEFT JOIN + NULL check (or NOT EXISTS)....
2 views
23 Jan 2026
Assume order_id should be continuous. Using a helper Numbers(n) table, list the missing order_id between MIN(order_id) and MAX(order_id)....
2 views
23 Jan 2026
For each department, return employee(s) who have the second highest salary. Use DENSE_RANK so ties are handled nicely....
3 views
23 Jan 2026
Create month-wise revenue and also show a rolling 3-month total. First aggregate by month, then apply a window sum over the last 3 months....
2 views
23 Jan 2026
Assume Payments.amount is negative for refunds. Find customers where total refund is more than 30% of total paid amount. Use conditional SUM....
2 views
23 Jan 2026
For each customer, show the first time they ordered and the most recent order date. This is a clean use of MIN and MAX....
2 views
23 Jan 2026
From OrderItems(order_id, product_id), count how often two products are bought in the same order. Return top 10 pairs by count....
2 views
23 Jan 2026
Return customer names trimmed and in uppercase....
2 views
23 Jan 2026
From Orders, return order_id and order_year....
2 views
23 Jan 2026
Show product_id and rounded price....
2 views
23 Jan 2026
Show customer_id and phone, but display 'NA' when phone is null....
2 views
23 Jan 2026
List products where name length is more than 20 characters....
5 views
23 Jan 2026
Show Orders with a formatted date string like YYYY-MM-DD....
2 views
23 Jan 2026
Create spend_bucket as LOW (20000) using CASE on total spend....
2 views
23 Jan 2026
Return top 3 orders by total_amount for each customer....
3 views
23 Jan 2026
For daily sales, show today_sales and change_from_yesterday....
2 views
23 Jan 2026
For Orders sorted by order_date, show running sum of total_amount....
3 views
23 Jan 2026
Find employees whose salary is above the 90th percentile in their department....
3 views
23 Jan 2026
Create a query that removes spaces and lowercases product names for matching a user input....
2 views
23 Jan 2026
In LoginLogs(user_id, logged_at), start a new session if gap > 30 minutes. Assign session_number per user....
3 views
23 Jan 2026
Compute the median of Orders.total_amount....
3 views
23 Jan 2026
Orders table is filtered by status a lot. Create an index on status....
2 views
23 Jan 2026
Customers are searched by (city, name). Create a composite index....
2 views
23 Jan 2026
Prevent duplicate SKU in Products using a unique index....
2 views
23 Jan 2026
Drop index idx_orders_status....
3 views
23 Jan 2026
Create an index for faster queries on Orders(order_date)....
2 views
23 Jan 2026
Query: SELECT * FROM Orders WHERE customer_id=? AND order_date BETWEEN ? AND ?. Suggest an index and write it....
2 views
23 Jan 2026
Query needs only (order_date, total_amount) for reports. Create an index that helps covering these columns....
2 views
23 Jan 2026
Orders joins OrderItems on order_id. Write index statements to support this join....
2 views
23 Jan 2026
You have a column gender with only 2 values. Should you index it? Provide a practical answer in description, and give no index statement....
2 views
23 Jan 2026
You want index only on active rows (status='ACTIVE'). Create a helper column active_flag and index it with customer_id....
4 views
23 Jan 2026
Write a query idea to list indexes that are not used often. Keep it simple and generic....
2 views
23 Jan 2026
Customers are searched by name starting with 'ra'. Write an index and a matching query....
3 views
23 Jan 2026
You already have index on (city, name). Someone wants another on city only. How do you decide? Put reasoning in description and leave sample_solution as a metadata check query....
5 views
23 Jan 2026
After deleting millions of rows, you want to rebuild an index. Provide a generic rebuild statement....
5 views
23 Jan 2026
List employee name with department name....
2 views
23 Jan 2026
List all customers and their latest order_id if any. Customers without orders should still show....
2 views
23 Jan 2026
Show order_id, customer name, and total_amount....
2 views
23 Jan 2026
Employees(emp_id, name, manager_id). Show employee name and manager name....
2 views
23 Jan 2026
Create all combinations of Sizes(s) and Colors(c) to generate SKU options....
3 views
23 Jan 2026
Find products that never appear in OrderItems....
2 views
23 Jan 2026
For each customer, show total paid amount in the last 30 days. Join Orders with Payments and group by customer....
3 views
23 Jan 2026
You have table A_ids(id) and B_ids(id). Show ids that are missing on either side....
2 views
23 Jan 2026
Students and Courses are many-to-many via Enrollment. Show student_name and course_name....
2 views
23 Jan 2026
For each customer, show details of their latest order (not just id)....
2 views
23 Jan 2026
Orders, OrderItems, Products. Show category-wise revenue for shipped orders only....
5 views
23 Jan 2026
Customers who have at least one purchase in each product category....
3 views
23 Jan 2026
Shifts(emp_id, start_time, end_time). Find employees whose shifts overlap on same day....
3 views
23 Jan 2026
Customers(city), Orders, OrderItems. For each city, find top 2 products by quantity sold....