This document contains the index and solutions for 12 SQL queries related to creating tables, inserting, deleting and selecting data from tables. The queries cover concepts like primary keys, aggregation, string functions, date functions and formatting. The solutions are provided step-by-step with the appropriate SQL commands to solve each query.
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 ratings0% found this document useful (0 votes)
41 views11 pages
Pratical File Term
This document contains the index and solutions for 12 SQL queries related to creating tables, inserting, deleting and selecting data from tables. The queries cover concepts like primary keys, aggregation, string functions, date functions and formatting. The solutions are provided step-by-step with the appropriate SQL commands to solve each query.
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
You are on page 1/ 11
DWARKA INTERNATIONAL
SCHOOL
INFORMATICSPRACTICES
PRACTICAL FILE 2021-2022
MADE BY- MONIKA RATHI
C LASS -12 DAISY S UBMITTED TO-MS. CHANCHAL INDEX S.NO TITLE TEACHER SIGN 1 CREATE TABLE STUDENT WITH STUDENTID, MARKS, NAME AS ATTRIBUTE WHERE STUDENTID IS THE PRIMARY KEY. 2 INSERT THE DETAILS OF A NEW STUDENT IN THE ABOVE TABLE. 3 DELETE THE DETAILS OF A STUDENT IN THE ABOVE TABLE . 4 USE THE SELECT COMMAND TO GET THE DETAILS OF STUDENTS WITH MARKS MORE THAN 80. 5 FIND THE MIN, MAX, SUM, AVERAGE OF MARKS IN A STUDENT MARKS TABLE. 6 FIND THE TOTAL NUMBER OF CUSTOMERS FROM EACH COUNTRY USING GROUP BY. 7 WRITE THE SQL QUERY TO ORDER THE TABLE IN DESCENDING ORDER OF MARKS. 8 WRITE A SQL QUERY TO DISPLAY THE MARKS WITHOUT DECIMAL PLACES, DISPLAY THE REMINDER AFTER DIVIDING MARKS BY 3, AND DISPLAY THE SQUARE OF MARKS. 9 WRITE A SQL QUERY TO DISPLAY THE NAME IN CAPITAL LETTERS, SMALL LETTERS, DISPLAY THE FIRST 3 LETTERS, DISPLAY LAST 3 LETTERS AND DISPLAY THE POSITION OF LETTER A IN THE NAME. 10 REMOVE EXTRA SPACES FROM LEFT, RIGHT, BOTH THE SIDES FROM TEXT” INFORMATICS PRACTICES CLASS XII”. 11 DISPLAY TODAYS DATE IN “DATE/MONTH/YEAR” FORMAT. 12 DISPLAY DAY NAME, MONTH NAME, DAY, DAY NAME, DAY OF MONTH, DAY OF YEAR FOR TODAYS DATE. 1.Create a student table with the student id, name, and marks as attributes where the student id is the primary key. Ans.: create table student (studentid int(1) primary key, name varchar(20), marks int(2));
2. Insert the details of a new student in the above
table. Ans.: insert into student values(1,’Shristi’,90), (2,’Harshita’,92),(3,’Diksha’,80),(4,’Sanovi’,85), (5,’Ashu’92); 3. Delete the details of a student in the above table. Ans.: delete from student where studentid=5;
4. Use the select command to get the details of the
students with marks more than 80. Ans.: select * from student where marks>80;
5. Find the min, max, sum, and average of the marks in
a student marks table. Ans.: select max(marks), min(marks), sum(marks) , avg(marks) from student;
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(customerid) 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; 9. Write a SQL query to display names into capital letters, small letters, display first 3 letters of name, display last 3 letters of name, display the position the letter A in name. Ans.: select ucase(name), lcase(name), left(name,3), right(name,3), instr(name,'a') from student; 10. Remove extra spaces from left, right and both sides from 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 ");
11. Display today's date in "Date/Month/Year" format.
Ans.: select concat(date(now()), concat("/",concat(month(now()), concat("/",year(now()))))); 12. Display day name, month name, day, day name, day of month, day of year for today's date. Ans.: select dayname(now()), monthname(now()), day(now()), dayname(now()), dayofmonth(now()), dayofyear(now());