0% found this document useful (0 votes)
2 views2 pages

SQL Assignment Questions Answers

The document contains a series of SQL assignment questions and answers, covering database creation, table management, data insertion, updates, deletions, and various queries. It includes commands for creating a 'shop' database, managing 'products' and 'customers' tables, and performing operations like counting, selecting distinct values, and calculating price statistics. Additionally, it addresses modifications to a 'members' table by adding an email column and updating member information.

Uploaded by

mahadevshiba7983
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views2 pages

SQL Assignment Questions Answers

The document contains a series of SQL assignment questions and answers, covering database creation, table management, data insertion, updates, deletions, and various queries. It includes commands for creating a 'shop' database, managing 'products' and 'customers' tables, and performing operations like counting, selecting distinct values, and calculating price statistics. Additionally, it addresses modifications to a 'members' table by adding an email column and updating member information.

Uploaded by

mahadevshiba7983
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

SQL Assignment Questions and Answers

Q1. Create database shop


CREATE DATABASE shop;

Q2. Use database


USE shop;

Q3. Create products


CREATE TABLE products (id INT PRIMARY KEY AUTO_INCREMENT,name
VARCHAR(100),price DECIMAL(8,2));

Q4. Insert products


INSERT INTO products (name,price) VALUES ('Laptop',55000.00),('Mobile',350.50),
('Keyboard',800.00),('Mouse',250.00),('Headphones',1200.00);

Q5. Update id=2


UPDATE products SET price=450.75 WHERE id=2;

Q6. Delete id=3


DELETE FROM products WHERE id=3;

Q7. Price>200
SELECT * FROM products WHERE price>200;

Q8. Create customers


CREATE TABLE customers (cust_id INT AUTO_INCREMENT PRIMARY KEY,cust_name
VARCHAR(50),city VARCHAR(50));

Q9. Insert customers


INSERT INTO customers (cust_name,city) VALUES ('Ram','Delhi'),('Shyam','Mumbai'),
('Sita','Delhi');

Q10. Distinct cities


SELECT DISTINCT city FROM customers;

Q11. Count products


SELECT COUNT(*) AS Total_Products FROM products;

Q12. Author ends n


SELECT * FROM books WHERE author LIKE '%n';
Q13. Books by price
SELECT * FROM books ORDER BY price ASC;

Q14. Top 3 books


SELECT * FROM books ORDER BY price DESC LIMIT 3;

Q15. Count members


SELECT COUNT(*) AS Total_Members FROM members;

Q16. Unique authors


SELECT DISTINCT author FROM books;

Q17. Max price


SELECT MAX(price) FROM books;

Q18. Min price


SELECT MIN(price) FROM books;

Q19. Avg price


SELECT AVG(price) FROM books;

Q20. Add email


ALTER TABLE members ADD email VARCHAR(100);

Q21. Update email


UPDATE members SET email='ram@[Link]' WHERE member_id=1;

You might also like