SQL Practical
SQL Practical
1 Create a student table with the student id, name, and marks as
attributes where the student id is the primary key.
2 Insert the details of a new student in the above table
Table data:
4. Use the select command to get the details of the students with marks more than
80.
Ans.:
select * from student where marks>80;
6. Find the total number of customers from each country in the table (customer ID,
customer Name, country) using group by.
Ans.:
select country, count(customer_id) from customer group by
country;
7. Write a SQL query to order the (student ID, marks) table in descending order of
the marks.
Ans.:
select * from student order by marks desc;
8. Write a SQL query to display the marks without decimal places, display the
reminder after diving marks by 3 and display the square of marks.
Ans.:
select round(marks,0),mod(marks,3),pow(marks,2) from
student;
10. Remove extra spaces from left, right and both sidesfrom the text - " Informatics
Practices Class XII "
Ans.:
select ltrim(" Informatics Practices Class XII ") "Left
Spaces", rtim(" Informatics Practices Class XII ") "Right
Trim", trim(" Informatics Practices Class XII ");