Dbms Assignment
Dbms Assignment
PHONE
GENDER SEM
SSID
USN
SEC
CLASS_MARKS
SECURES
CREDITS SEM
SCORED_IN
IAMARKS SUBJECT
TEST 1
TEST3
TITLE
SUBCODE
TEST2
FINAL IA
ASSIGNMENT-2
Q1. Create table students . Write queries to execute following DDL commands :
1. CREATE: Create the structure of a table with at least five columns
2. ALTER: Change the size of a particular column.
3. Add a new column to the existing table.
4. Remove a column from the table.
5. DROP: Destroy the table along with its data.
Answer:-
1. CREATE: Create the structure of a table with at least five columns
1. INSERT: Insert five records into each table with sample data.
2. Modify data in single and multiple columns in a table.
Answer:-
1. Modify the salary of employee with ID 3 to 54000.00.
Q5. Display the details of those employees whose salary is greater than the average
salary in the organization.
Q6. Display the details of the employee whose Department location is Noida.
Q7. Display the Department Locations to which employees belong.
Question 2: How would you extract the first 3 characters from the product
names in the "Electronics" category?
Question 3: Find all products where the product name contains the word
'smartphone'.
Question 4: Retrieve products with names ending in 's' and having a price
greater than $500.
Question 5: How can you concatenate the product name and category,
separated by a hyphen, for all products?
Logical Operators:
Question 1: Retrieve products with a price greater than $100 and a stock
quantity less than 50.
Question 2: Find products with a price less than $50 or a stock quantity greater
than 100.
Question 5: Retrieve products with a price between $50 and $100 and not in the
'Electronics' category.
Conditional Operator:
Question 1: Retrieve products with a price greater than $100 and label them as
'Expensive'.
Question 2: Retrieve products with a stock quantity less than 50 and label them
as 'Low Stock'.
Question 3: Retrieve products with a price between $50 and $100 and categorize
them as 'Standard'.
Question 4: Retrieve products in the 'Electronics' category with a stock
quantity greater than 100 and label them as 'High Demand'.
Question 5: Retrieve products with a price less than $50 and categorize them as
'Budget'.
Sorting
Question 1: Write an SQL query to retrieve all products from the Products
table sorted by their price in ascending order
.
Question 2: How would you retrieve products from the Clothing category
sorted alphabetically by their product names in descending order?
Question 3: Find all products from the Electronics category sorted by their
stock quantity in descending order.
Question 4: Retrieve products with a price greater than $50 sorted by their
price in descending order and then by their category in ascending order