Posts

Showing posts from April, 2024

3 here

 Week 3: Week-3 Problems Create University database by copying it from other user. Write SQL Select Statements for the following simple queries that retrieve data from a single table: Find the details of all students. SQL> select * from student; ID NAME DEPT_NAME TOT_CRED ----- -------------------- -------------------- ---------- 00128 Zhang Comp. Sci. 102 12345 Shankar Comp. Sci. 32 19991 Brandt History 80 23121 Chavez Finance 110 44553 Peltier Physics 56 45678 Levy Physics 46 54321 Williams Comp. Sci. 54 55739 Sanchez Music 38 70557 Snow Physics 0 76543 Brown Comp. Sci. 58 76653 Aoi Elec. Eng. ...

6-12 here

Week 6:  Aggregate Functions: 1. Find the total sales amount for each product category: SELECT category, SUM(sales_amount) AS total_sales FROM sales GROUP BY category; JOINs: 2. Retrieve customer information along with their orders: SELECT c.customer_id, c.name, o.order_id, o.order_date FROM customers c INNER JOIN orders o ON c.customer_id = o.customer_id; Subqueries: 3.Find customers who have placed orders in the last month: SELECT customer_id, name FROM customers WHERE customer_id IN (     SELECT DISTINCT customer_id     FROM orders     WHERE order_date >= TRUNC(SYSDATE, 'MM') - INTERVAL '1' MONTH ); Common Table Expressions (CTEs): 4.Find the top 3 best-selling products: WITH ranked_products AS (     SELECT product_id, SUM(quantity) AS total_sold,            RANK() OVER (ORDER BY SUM(quantity) DESC) AS sales_rank     FROM order_details     GROUP BY product_id ) SELECT p.product_name, rp....