Open navigation menu
Close suggestions
Search
Search
en
Change Language
Upload
Sign in
Sign in
Download free for days
0 ratings
0% found this document useful (0 votes)
11 views
Deepika Mysql
SQL file
Uploaded by
preeti
AI-enhanced title
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here
.
Available Formats
Download as PDF or read online on Scribd
Download now
Download
Save deepika mysql For Later
Download
Save
Save deepika mysql For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
0 ratings
0% found this document useful (0 votes)
11 views
Deepika Mysql
SQL file
Uploaded by
preeti
AI-enhanced title
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here
.
Available Formats
Download as PDF or read online on Scribd
Download now
Download
Save deepika mysql For Later
Carousel Previous
Carousel Next
Save
Save deepika mysql For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
Download now
Download
You are on page 1
/ 16
Search
Fullscreen
Practical MySQLPRATICAL 1 Problem statement: Create a students table with the student id, name, and marks as attributes ‘where the student id is the primary key. Solution: To cteate a student table with studid, name, and marks as attributes in MySQL, where student_id is the primary key, you can use the following SQL statement: Source Code: create table student {studid int primary key, narne varchar(30), marks int hi forte eee aa eu (studid int primary key, name varchar(30), Etats -> ); Query OK, © rows affected (0.02PRATICAL 2 Problem statement: In the table ‘student’ created in practical 26, insert the details of new students. Solution: This command inserts 10 rows into the student table, where each student has a unique student_id, aname, anda marks value. Make sure that student_id values are unique and that they follow the primary key constraints. Source Code: INSERT INTO student (studid, name, marks} VALUES (1, Rahul Sharma; 85), (2, ‘Priya Singh’, 78), (3, Amit Patet, 82), (4, Sneha Gupta’. 88), (5, ‘Rohan Das’, 74), (6, ‘Anjali Mehta’, 90), (7, "Vikram Rao, 80), (8, Pooja Nair’. 76) (9, Karan Verma’ 81), (10, "Neha Joshi, 83); mysql> INSERT INTO student (studid, name, marks) VALUES -> (1, ‘Rahul Sharma', 85), @, ‘Priya Singh', 78), cee Urea ey (4, ‘Sneha Gupta’, 88), (5, ‘Rohan Das', 74), (6, ‘Anjali Mehta! , 99), (7, ‘Vikram Rao', 89), (8, ‘Pooja Nair’, 76), (9, ‘Karan Verma’, 81), (10, "Neha Joshi', 89); Query OK, 10 rows affected (0.01 sec) Records: 10 Duplicates: © Warnings:PRATICAL 3 Problem statement: ‘Write SQL command to get the details of the students with marks more than 80. Solution: This command selects all columns (*) from the student table where the marks column has a value greater than 80. It will return the studid, name, and marks of each student who meets this condition, Source Code: SELECT * FROM student WHERE marks > 80; mysql> SELECT * FROM student rai i,t MPa | 7 EU Pe) Sharma vba tee Sneha Gupta rOPeiemn ote Karan Verma Neha Joshi rows in set (0.00 sec)PRATICAL 4 Problem statement: ‘Write SQL command to Find the min, max, sum, and average of the marks in a student marks table, Solution: + min_marks: The minimum marks in the table. * max_marks: The maximum marks in the table. ‘+ total_marks: The sum of all marks. * average_marks: The average marks of all students, Each of these values will be calculated from the marks column in the student table. Source Code: SELECT MIN(marks) AS min_marks, MAX(marks) AS max_marks, SUM(marks) AS total_marks, AVG(marks) AS average_marks FROM student; een MIN(marks) Cees te MAX (marks) Cea baa SUM(marks) A Mee Cea co Macrae CEC EarT Ts [a-) eesate cits + oe one on row in set (0.00 sec)PRATICAL 5 Problem statement: Delete the details of a student table created in Practical 26. Solution: The DELETE FROM student; command clears all data from the student table but keeps the table structure. The DROP TABLE student; command permanently removes the table and all its contents from the database. Use this with caution, as it cannot be undone. Source Code DELETE FROM student; DROP TABLE student;PRATICAL 6 Problem statement: Find the total number of customers from each country in the table (customer ID, customer Name, country) using group by. Solution: This command groups the data by country and counts the number of customer_id entries in each group, resulting in the total number of customers per country. The output will show each country with the corresponding count of customers. Source Code: SELECT country, COUNT(customer_id) AS total_custorners FROM customer GROUP BY country; \> SELECT country, COUNT(customer_id) AS total_customers Sema Seco ake Cos eye India| To | Canada | UK | rows in set (0.00 sec)PRATICAL 7 Problem statement: ‘Write a SQL query to order the (student ID, marks) table in descending order of the marks. Solution: This command will display the studid and marks columns, sorted in descending order based on the marks column, with the highest marks appearing first. Source Code: SELECT studid, marks FROM student ‘ORDER BY marks DESC; mysql> SELECT studid, marks pees mets Lk -> ORDER BY marks DESC; 7 7 studid | marks | | | | | | | | | | | + 10 rows in set (0.00 sec)PRATICAL 8 Problem statement: For the given table ‘Hospital’ write SQL command to display name all patient admitted in month of May. PID [PNAME [apmiTpate | DepT__| Fees ‘AP/PT/O01 | Arjun Verma [21-04-2019 | ENT 250 AP/PT/O02 | NeelamReddy | 12-05-2019 | Cardio 400 ‘AP/PT/003 | Kavita Singh [19-05-2019 | Cardio 400 APIPT/ON4 | Vikram Patel _| 24-06-2019 | Neuro 600 Solution: To display the names of all patients admitted in the month of May from the Hospital table, you can use the following SQL query. This query assumes the ADMITDATE is stored as a date in the DD/MM/YYYY format (or similar) and filters the records where the admission date falls in May. Source Code: SELECT PNAME FROM Hospital WHERE MONTH(ADMITDATE) mysql> SELECT PNAME es aCe ae Psa ea US eas ak at + Neelam Reddy | Kavita Singh | = rows in set (0.00 sec)PRATICAL 9 Problem statement: for the given table ‘Hospital’ write SQL command to Display patient name in upper case with ‘year of admission, PID AP/PT/OOL AP/PT/OO2 AP/PT/O03 APIPT/OOA Solution: PNAME [Arjun Verma [Neelam Reddy [ Kavita Singh Vikram Patel [ApMimpate | DEPT | FEES [21-04-2019 | ENT 250 [12-05-2019 | Cardio 400 [19-05-2019 | Cardio 400 24-06-2019 | Neuro 600 UPPER(PNAME): Converts the PNAME (patient name) to uppercase. YEAR(ADMITDATE): Extracts the year from the ADMITDATE. Source Code: SELECT UPPER(PNAME) AS patient_name, YEAR(ADMITDATE) AS admission_year FROM Hospital; ean emai Poa sccm VIKRAM PATEL | + eon operant aaa 2019 2019 i 2019 | I 1 2019 | + Taner Cat mrePRATICAL 10 Problem statement: for the given table ‘Hospital’ Create sql query to display first four Letters of the patientname along with length of their name who admitted before may. PID. PNAME ADMITDATE | DEPT | FEES ‘ap/PT/001 | Arjun Verma | 21-04-2019 | ENT 250 AP/PT/002 | Neelam Reddy | 12-05-2019 | Cardio 400 Ap/PT/003 | Kavita Singh [19-05-2019 | Cardio 400 AP/PT/004 | Vikram Patel 24-06-2019 | Neuro 600 Solution: LEFT(PNAME, 4): Extracts the first four Letters of the patient name (PNAME), LENGTH(PNAME): Calculates the length of the patient name. WHERE MONTH(ADMITDATE) <5: Filters to include only patients admitted before May {i.e., months 1 to 4). Source Code: SELECT LEFT(PNAME, 4) AS first_four_letters, LENGTH (PNAME) AS name_length FROM Hospital WHERE MONTH(ADMITDATE) <5; ELECT LEFT( eer ee eae Se Same ayPRATICAL 11 Problem statement: Retrieve the list of students sorted by their marks in descending order. This sorting will facilitate quick identification of high achievers. [ name stream | marks wl | Scienes | 2 | Priya Singh Commerce | 78 | [ 3 | AmitPatet Arts 92 I 4 | Sneha Gupta Science 88 | 5 | Rohan Das Commerce 74 I 6 | Anjali Mehta Arts: 90 I 7 | Vikram Rao Science | 80 | | & | Pooja Nair 9 | Karan Verma 10 | Neha Joshi Science Solution: ORDER BY marks DESC: Sorts the list by the marks column in descending order, so the students with the highest marks appear at the top. Source Code: SELECT studid, name, marks FROM student ORDER BY marks DESC; Sree ager Cee? => FROM student See Veer a afer i tudid cued Anit Patel | PUSreaL icaPRATICAL 12 Problem statement: Generate a list of students sorted first by their stream and then by their marks in descending order. This will atlow for a comparative analysis of performance across different streams { student id | name stream | marks | | Rahul Sharma Science| 85. 2 | Priya Singh Commerce | _78 | | 3 | Amit Patel Arts 92 | 4 | Sneha Gupta Science 88 | 5 | Rohan Das Commerce 74 | 6 | Anjali Mehta Arts I 7 | Vikram Rao Science | Nair I Karan Verma ___ Arts | I [Neha Joshi Science Solution: ORDER BY stream, marks DESC: Sorts the students first by stream (alphabetically) and then within each stream by marks in descending order. Source Code: SELECT studid, name, stream, marks FROM student ORDER BY stream, marks DESC; SerePRATICAL 13 Problem statement: Retrieve students’ names and their marks, sorting the results by marks using an alias for clarity. This provides a clean and organized view of student performance. student, me stream [-___1 | RanutShamma [Science | Commerce 2 | Amit Patet Arts 4 | Sneha Gupta Science 5 | Rohan Das Commerce 6 | Anjali Menta Arts 7 | Vikram Rao Science 8 | Pooja Nair Commerce | 9 | Karan Verma Arts 10 | Neha Joshi Science Solution: ‘© name AS student_name: Renames name to student_name fora clear, descriptive alias. ‘© marks AS student_marks: Renames marks to student_marks. + ORDER BY student_marks DESC: Sorts the results by marks in descending order to display the highest marks at the top. This query provides a well-organized view of student performance with clear column names. Source Code: SELECT name AS student_name, marks AS student_marks FROM student ‘ORDER BY student_marks DESC;PRATICAL 14 Problem statement: Calculate the average marks for each stream in the students table. This grouping will help identify which streams are performing well and which may need curricular improvements. [student id [ name stream marks [ 1 | Rahul Sharma Science | 85 [ 2 | Priya Singh Commerce 8 | 3 | Amit Patet Arts | 92 | 4 | Sneha Gupta Science 88 [ | Rohan Das Commerce | 74 | 6 | Anjali Mehta ‘Arts 20 | 7_| Vikram Rao Science 80 | | @ | Karan Verma 410 | Neha Joshi Science Solution: + AVG(marks) AS average_marks: Calculates the average marks for each stream and renames it to average_marks for clarity. ‘© GROUP BY stream: Groups the students by stream, so the average is calculated for each stream separately. This query will provide a list of streams along with the average marks, allowing for a comparative analysis of performance across different streams Source Code: SELECT stream, AVG(marks) AS average_marks FROM student GROUP BY stream; corer CyPRATICAL 15 Determine the number of distinct streams present in the students table. This will provide insights into the diversity of academic programs within the institution. [student id [ name stream | marks I 1.| Rahul Sharma Science | 85 | 2 | Priya Singh Commerce 78 | 3 | Amit Patel Arts | 92 | 4 | Sneha Gupta Science 88 I 5 | Rohan Das Commerce | 74 | 6 | AnjaliMehta Arts 7[VikramRao——«|—Science | 80 | 8 | Pooja Nair Commer: 76 | 9 | Karan Verma _ Arts En I 20 | Nena Joshi Science | a8 | Solution: COUNTIDISTINGT stream): Counts the unique values in the stream column to find the number of distinct streams. AS total_ streams: Renames the result as total_streams for clarity. Source Cade: SELECT COUNT(DISTINCT stream) AS total_streamns FROM student; mysql> SELECT COUNT(DISTINCT stream) AS total_streams FROM student;
You might also like
MySQL Practical
PDF
No ratings yet
MySQL Practical
21 pages
KJJJHJJJHG
PDF
No ratings yet
KJJJHJJJHG
16 pages
mysql-prctical1
PDF
No ratings yet
mysql-prctical1
2 pages
ASHWIN
PDF
No ratings yet
ASHWIN
13 pages
Mysql Questions
PDF
No ratings yet
Mysql Questions
7 pages
1) Create A Student Table With Student - Id, Name and Marks As Attributes Where Student - Id Is Primary Key SQL Create Table Student
PDF
60% (5)
1) Create A Student Table With Student - Id, Name and Marks As Attributes Where Student - Id Is Primary Key SQL Create Table Student
5 pages
Practical File Mysql
PDF
100% (2)
Practical File Mysql
4 pages
IPPracticals SQL 2022-23
PDF
No ratings yet
IPPracticals SQL 2022-23
8 pages
practical program sql (2)
PDF
No ratings yet
practical program sql (2)
12 pages
SQL Experiment Ans
PDF
No ratings yet
SQL Experiment Ans
16 pages
SQL-Query
PDF
No ratings yet
SQL-Query
5 pages
Math/Numeric Functions: - Power /pow - Round - Truncate - Mod - SQRT
PDF
No ratings yet
Math/Numeric Functions: - Power /pow - Round - Truncate - Mod - SQRT
11 pages
Untitled document (1)
PDF
No ratings yet
Untitled document (1)
13 pages
SQL Queries 12 Ip
PDF
No ratings yet
SQL Queries 12 Ip
12 pages
Practical File Term 2 (INFORMATICS PRACTICES)
PDF
No ratings yet
Practical File Term 2 (INFORMATICS PRACTICES)
17 pages
My SQL Lab Answers Tables 1-3
PDF
No ratings yet
My SQL Lab Answers Tables 1-3
13 pages
Single Table
PDF
No ratings yet
Single Table
8 pages
My SQL Project
PDF
No ratings yet
My SQL Project
47 pages
G12 Practical SQL Commands 2024-2025 (2)
PDF
No ratings yet
G12 Practical SQL Commands 2024-2025 (2)
5 pages
DBMS Pactical File SS
PDF
No ratings yet
DBMS Pactical File SS
21 pages
My SQL
PDF
No ratings yet
My SQL
3 pages
Demo Commands
PDF
No ratings yet
Demo Commands
11 pages
IP - Xii - Lab Programs
PDF
No ratings yet
IP - Xii - Lab Programs
18 pages
Lab Ism 2
PDF
No ratings yet
Lab Ism 2
152 pages
sql101 Reference Guide
PDF
No ratings yet
sql101 Reference Guide
12 pages
SQL_practicesheet_ANSKEY
PDF
No ratings yet
SQL_practicesheet_ANSKEY
15 pages
SQL Term 2 Comp Practical
PDF
No ratings yet
SQL Term 2 Comp Practical
8 pages
SQL Advanced
PDF
No ratings yet
SQL Advanced
60 pages
MIS 406 Final Practical Assignment 2018-2!10!017
PDF
No ratings yet
MIS 406 Final Practical Assignment 2018-2!10!017
27 pages
IT130-44-Week 6 Lecture Notes
PDF
No ratings yet
IT130-44-Week 6 Lecture Notes
7 pages
Relational Language
PDF
No ratings yet
Relational Language
69 pages
DB Command
PDF
No ratings yet
DB Command
2 pages
Ip Practical Shubham.pdf
PDF
No ratings yet
Ip Practical Shubham.pdf
20 pages
CLASS 12 IP PRACTICAL FILE (2)-pages-deleted (1)-output
PDF
No ratings yet
CLASS 12 IP PRACTICAL FILE (2)-pages-deleted (1)-output
17 pages
SQL Operators
PDF
No ratings yet
SQL Operators
4 pages
DBMS Record
PDF
No ratings yet
DBMS Record
53 pages
Practical Programs from Mysql
PDF
No ratings yet
Practical Programs from Mysql
3 pages
SQL: Structured Query Language
PDF
No ratings yet
SQL: Structured Query Language
38 pages
mysql_DPS_lab record_xi
PDF
No ratings yet
mysql_DPS_lab record_xi
8 pages
SQL Lab Manual 2
PDF
No ratings yet
SQL Lab Manual 2
8 pages
Informatics Practices Practical 12 Class
PDF
No ratings yet
Informatics Practices Practical 12 Class
22 pages
FALLSEM2021-22 CBS1007 ELA VL2021220104396 Reference Material I 06-Aug-2021 LAB1 SQL
PDF
No ratings yet
FALLSEM2021-22 CBS1007 ELA VL2021220104396 Reference Material I 06-Aug-2021 LAB1 SQL
59 pages
Pratical4 DBMS
PDF
No ratings yet
Pratical4 DBMS
15 pages
IP practical 12
PDF
No ratings yet
IP practical 12
6 pages
Dbms MCQ Sheet-2
PDF
No ratings yet
Dbms MCQ Sheet-2
6 pages
Database Management Systems Lab Lab 1 and 2: Create Table Student (Rno, Name, DOB, Gender, Class, College, City, Marks)
PDF
No ratings yet
Database Management Systems Lab Lab 1 and 2: Create Table Student (Rno, Name, DOB, Gender, Class, College, City, Marks)
6 pages
SQL Cheat Sheet
PDF
No ratings yet
SQL Cheat Sheet
15 pages
Dhruv Pillai IP Project#
PDF
No ratings yet
Dhruv Pillai IP Project#
10 pages
doc1
PDF
No ratings yet
doc1
2 pages
A Quick Guide To Mysql Tables & Queries: Inserting Data
PDF
No ratings yet
A Quick Guide To Mysql Tables & Queries: Inserting Data
2 pages
Manual No 3
PDF
No ratings yet
Manual No 3
8 pages
Yet More SQL Select: Database Systems Lecture 9
PDF
No ratings yet
Yet More SQL Select: Database Systems Lecture 9
30 pages
DBMS Pactical File SS
PDF
No ratings yet
DBMS Pactical File SS
20 pages
Dinesh IT File
PDF
No ratings yet
Dinesh IT File
36 pages
1.DDL Commands: 1. Creating A Table
PDF
No ratings yet
1.DDL Commands: 1. Creating A Table
6 pages
RecordNote_mysql_query
PDF
No ratings yet
RecordNote_mysql_query
12 pages
SQL & Databases - Subqueries
PDF
No ratings yet
SQL & Databases - Subqueries
22 pages
Information Practices HW Answers
PDF
No ratings yet
Information Practices HW Answers
2 pages
60 ATL Tcil - Sheet8
PDF
No ratings yet
60 ATL Tcil - Sheet8
7 pages
MCS213 SOFTWARE ENGINEERING Compressed
PDF
No ratings yet
MCS213 SOFTWARE ENGINEERING Compressed
20 pages
Adobe Scan 21-Nov-2024
PDF
No ratings yet
Adobe Scan 21-Nov-2024
3 pages
MCS215 SECURITY&CYBERLAWS Compressed
PDF
No ratings yet
MCS215 SECURITY&CYBERLAWS Compressed
32 pages
Class 12 CS Practice Paper 2024-25
PDF
No ratings yet
Class 12 CS Practice Paper 2024-25
38 pages
XIIInfo Pract 37
PDF
No ratings yet
XIIInfo Pract 37
4 pages