Practical on SQL (12)
- Create a database College.
- Delete a database College.
- Create a database OurSchool.
- Use database OurSchool.
- Create a table student with rollno, class, studentid, sname, address, phone, salary with suitable variable.
- Create a table parents with sno, studentid, parentname, phone, address
- Create a table persons with a primary key field.
- Delete a column salary from student table.
- Insert any 5 records into student table.
- Display all the records.
- Display only class 11 records. (Record must be in table)
- Display only name and address of class 12 records. (Record must be in table)
- Add a column section to student table.
- Update your table field section from varchar(50) into varchar(3)
- Update section to all the students.
- Update name from Ram to Shyam whose roll no is 10. (Record must be in table)
- Delete a single record whose roll no is 5 from student table.
- Delete all the data from student table.
- Delete student table.
- Make a
auto increment for sno field in a table.
- Display only unique records from the column of a table.
- Display all the records whose address is butwal.
- Update all the records whose address is butwal to Kathmandu.
- Delete all the records whose address is Kathmandu.
- Display all the detail of roll no 5.
- Display all the records whose Class is 12 and age is 13.
- Display all the records whose address is Pokhara or Bhairawaha.
- Display all the records whose age is not less than 18.
- Display all the records whose country is Nepal and city is Pokhara or Bhairawaha.
- Display all the records whose country is not Germany and Not USA.
- Select all the records ordered by name in ascending order.
- Select all the records ordered by salary in descending order.
- Arrange the records by Country and Customer Name. (If coutry will be same then it checks for the customer's name)
- Display all the records where address field is null.
- Display all the records where phone number field is filled.
- Display all the records for first 10 records only.
- Display only first 50% records only.
- Display first three records' whose country is Nepal.
- Find the cheapest price from the products.
- Find the expensive price from the products.
- Find the total number of records from the country Nepal.
- Find the average price of a product.
- Calculate the sum of all product of a specific brand.
- Find total price of order.
- Display all the products whose name starts from a.
- Display all the products whose name ends with a.
- Display all the records whose name have r in second position.
- Display all the records whose name have at least 3 characters and a is in second position.
- Display all the records whose city starts from a,b,c,d,e.
- Display all the records whose city does not starts from a,b,c,d,e.
- Select all the records whose customers that are located in Butwal, Pokhara, Kathmandu.
- Select all the records whose products price is in between 20000 and 50000.
- Select all the records whose products price is in between 20000 and 50000.
- Select all the records ordered by product name whose address is Butwal and Kathmandu.
- Select all the records whose order is between 05/07/2022 and 05/07/2023.
- Display all the records from customer, CustomerID as ID and customername as customer.
- Display all the records from customer and while displaying combine address, postalcode, city, country as Address.
- Solve the following.
- Notice that the "CustomerID" column in the "Orders" table refers to the "CustomerID" in the "Customers" table. The relationship between the two tables above is the "CustomerID" column.
- Then, we can
create the following SQL statement (that contains an
INNER JOIN
), that selects records that have matching values in both tables:
- (INNER) JOIN: Returns records that have matching values in
both tables
- LEFT (OUTER)
JOIN: Returns all records from the left table, and
the matched records from the right table
- RIGHT (OUTER)
JOIN: Returns all records from the right table, and
the matched records from the left table
- FULL (OUTER) JOIN: Returns all records when there is a match in either left or right table
62. Join only distinct data from any two tables.
Comments
Post a Comment