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)
9 views
Deepika Mysql
SQL file
Uploaded by
preeti
AI-enhanced title
Copyright
© © All Rights Reserved
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)
9 views
Deepika Mysql
SQL file
Uploaded by
preeti
AI-enhanced title
Copyright
© © All Rights Reserved
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
The Subtle Art of Not Giving a F*ck: A Counterintuitive Approach to Living a Good Life
From Everand
The Subtle Art of Not Giving a F*ck: A Counterintuitive Approach to Living a Good Life
Mark Manson
4/5 (6129)
Principles: Life and Work
From Everand
Principles: Life and Work
Ray Dalio
4/5 (627)
The Gifts of Imperfection: Let Go of Who You Think You're Supposed to Be and Embrace Who You Are
From Everand
The Gifts of Imperfection: Let Go of Who You Think You're Supposed to Be and Embrace Who You Are
Brené Brown
4/5 (1148)
Never Split the Difference: Negotiating As If Your Life Depended On It
From Everand
Never Split the Difference: Negotiating As If Your Life Depended On It
Chris Voss
4.5/5 (934)
The Glass Castle: A Memoir
From Everand
The Glass Castle: A Memoir
Jeannette Walls
4/5 (8215)
Grit: The Power of Passion and Perseverance
From Everand
Grit: The Power of Passion and Perseverance
Angela Duckworth
4/5 (631)
Sing, Unburied, Sing: A Novel
From Everand
Sing, Unburied, Sing: A Novel
Jesmyn Ward
4/5 (1253)
The Perks of Being a Wallflower
From Everand
The Perks of Being a Wallflower
Stephen Chbosky
4/5 (8365)
Shoe Dog: A Memoir by the Creator of Nike
From Everand
Shoe Dog: A Memoir by the Creator of Nike
Phil Knight
4.5/5 (860)
Her Body and Other Parties: Stories
From Everand
Her Body and Other Parties: Stories
Carmen Maria Machado
4/5 (877)
The Hard Thing About Hard Things: Building a Business When There Are No Easy Answers
From Everand
The Hard Thing About Hard Things: Building a Business When There Are No Easy Answers
Ben Horowitz
4.5/5 (361)
Hidden Figures: The American Dream and the Untold Story of the Black Women Mathematicians Who Helped Win the Space Race
From Everand
Hidden Figures: The American Dream and the Untold Story of the Black Women Mathematicians Who Helped Win the Space Race
Margot Lee Shetterly
4/5 (954)
Steve Jobs
From Everand
Steve Jobs
Walter Isaacson
4/5 (2923)
The Emperor of All Maladies: A Biography of Cancer
From Everand
The Emperor of All Maladies: A Biography of Cancer
Siddhartha Mukherjee
4.5/5 (277)
Elon Musk: Tesla, SpaceX, and the Quest for a Fantastic Future
From Everand
Elon Musk: Tesla, SpaceX, and the Quest for a Fantastic Future
Ashlee Vance
4.5/5 (484)
A Man Called Ove: A Novel
From Everand
A Man Called Ove: A Novel
Fredrik Backman
4.5/5 (4972)
Angela's Ashes: A Memoir
From Everand
Angela's Ashes: A Memoir
Frank McCourt
4.5/5 (444)
Brooklyn: A Novel
From Everand
Brooklyn: A Novel
Colm Toibin
3.5/5 (2061)
The Art of Racing in the Rain: A Novel
From Everand
The Art of Racing in the Rain: A Novel
Garth Stein
4/5 (4281)
The Yellow House: A Memoir (2019 National Book Award Winner)
From Everand
The Yellow House: A Memoir (2019 National Book Award Winner)
Sarah M. Broom
4/5 (100)
The Little Book of Hygge: Danish Secrets to Happy Living
From Everand
The Little Book of Hygge: Danish Secrets to Happy Living
Meik Wiking
3.5/5 (447)
Yes Please
From Everand
Yes Please
Amy Poehler
4/5 (1987)
Devil in the Grove: Thurgood Marshall, the Groveland Boys, and the Dawn of a New America
From Everand
Devil in the Grove: Thurgood Marshall, the Groveland Boys, and the Dawn of a New America
Gilbert King
4.5/5 (278)
The World Is Flat 3.0: A Brief History of the Twenty-first Century
From Everand
The World Is Flat 3.0: A Brief History of the Twenty-first Century
Thomas L. Friedman
3.5/5 (2283)
Bad Feminist: Essays
From Everand
Bad Feminist: Essays
Roxane Gay
4/5 (1068)
The Outsider: A Novel
From Everand
The Outsider: A Novel
Stephen King
4/5 (1993)
The Woman in Cabin 10
From Everand
The Woman in Cabin 10
Ruth Ware
3.5/5 (2641)
A Tree Grows in Brooklyn
From Everand
A Tree Grows in Brooklyn
Betty Smith
4.5/5 (1936)
The Sympathizer: A Novel (Pulitzer Prize for Fiction)
From Everand
The Sympathizer: A Novel (Pulitzer Prize for Fiction)
Viet Thanh Nguyen
4.5/5 (125)
A Heartbreaking Work Of Staggering Genius: A Memoir Based on a True Story
From Everand
A Heartbreaking Work Of Staggering Genius: A Memoir Based on a True Story
Dave Eggers
3.5/5 (692)
Team of Rivals: The Political Genius of Abraham Lincoln
From Everand
Team of Rivals: The Political Genius of Abraham Lincoln
Doris Kearns Goodwin
4.5/5 (1912)
Wolf Hall: A Novel
From Everand
Wolf Hall: A Novel
Hilary Mantel
4/5 (4074)
On Fire: The (Burning) Case for a Green New Deal
From Everand
On Fire: The (Burning) Case for a Green New Deal
Naomi Klein
4/5 (75)
Fear: Trump in the White House
From Everand
Fear: Trump in the White House
Bob Woodward
3.5/5 (830)
Manhattan Beach: A Novel
From Everand
Manhattan Beach: A Novel
Jennifer Egan
3.5/5 (901)
Rise of ISIS: A Threat We Can't Ignore
From Everand
Rise of ISIS: A Threat We Can't Ignore
Jay Sekulow
3.5/5 (143)
John Adams
From Everand
John Adams
David McCullough
4.5/5 (2544)
The Light Between Oceans: A Novel
From Everand
The Light Between Oceans: A Novel
M L Stedman
4.5/5 (790)
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
MCS215 SECURITY&CYBERLAWS Compressed
PDF
No ratings yet
MCS215 SECURITY&CYBERLAWS Compressed
32 pages
Adobe Scan 21-Nov-2024
PDF
No ratings yet
Adobe Scan 21-Nov-2024
3 pages
XIIInfo Pract 37
PDF
No ratings yet
XIIInfo Pract 37
4 pages
Class 12 CS Practice Paper 2024-25
PDF
No ratings yet
Class 12 CS Practice Paper 2024-25
38 pages
The Unwinding: An Inner History of the New America
From Everand
The Unwinding: An Inner History of the New America
George Packer
4/5 (45)
Little Women
From Everand
Little Women
Louisa May Alcott
4/5 (105)
The Constant Gardener: A Novel
From Everand
The Constant Gardener: A Novel
John le Carré
3.5/5 (109)
Related titles
Click to expand Related Titles
Carousel Previous
Carousel Next
The Subtle Art of Not Giving a F*ck: A Counterintuitive Approach to Living a Good Life
From Everand
The Subtle Art of Not Giving a F*ck: A Counterintuitive Approach to Living a Good Life
Principles: Life and Work
From Everand
Principles: Life and Work
The Gifts of Imperfection: Let Go of Who You Think You're Supposed to Be and Embrace Who You Are
From Everand
The Gifts of Imperfection: Let Go of Who You Think You're Supposed to Be and Embrace Who You Are
Never Split the Difference: Negotiating As If Your Life Depended On It
From Everand
Never Split the Difference: Negotiating As If Your Life Depended On It
The Glass Castle: A Memoir
From Everand
The Glass Castle: A Memoir
Grit: The Power of Passion and Perseverance
From Everand
Grit: The Power of Passion and Perseverance
Sing, Unburied, Sing: A Novel
From Everand
Sing, Unburied, Sing: A Novel
The Perks of Being a Wallflower
From Everand
The Perks of Being a Wallflower
Shoe Dog: A Memoir by the Creator of Nike
From Everand
Shoe Dog: A Memoir by the Creator of Nike
Her Body and Other Parties: Stories
From Everand
Her Body and Other Parties: Stories
The Hard Thing About Hard Things: Building a Business When There Are No Easy Answers
From Everand
The Hard Thing About Hard Things: Building a Business When There Are No Easy Answers
Hidden Figures: The American Dream and the Untold Story of the Black Women Mathematicians Who Helped Win the Space Race
From Everand
Hidden Figures: The American Dream and the Untold Story of the Black Women Mathematicians Who Helped Win the Space Race
Steve Jobs
From Everand
Steve Jobs
The Emperor of All Maladies: A Biography of Cancer
From Everand
The Emperor of All Maladies: A Biography of Cancer
Elon Musk: Tesla, SpaceX, and the Quest for a Fantastic Future
From Everand
Elon Musk: Tesla, SpaceX, and the Quest for a Fantastic Future
A Man Called Ove: A Novel
From Everand
A Man Called Ove: A Novel
Angela's Ashes: A Memoir
From Everand
Angela's Ashes: A Memoir
Brooklyn: A Novel
From Everand
Brooklyn: A Novel
The Art of Racing in the Rain: A Novel
From Everand
The Art of Racing in the Rain: A Novel
The Yellow House: A Memoir (2019 National Book Award Winner)
From Everand
The Yellow House: A Memoir (2019 National Book Award Winner)
The Little Book of Hygge: Danish Secrets to Happy Living
From Everand
The Little Book of Hygge: Danish Secrets to Happy Living
Yes Please
From Everand
Yes Please
Devil in the Grove: Thurgood Marshall, the Groveland Boys, and the Dawn of a New America
From Everand
Devil in the Grove: Thurgood Marshall, the Groveland Boys, and the Dawn of a New America
The World Is Flat 3.0: A Brief History of the Twenty-first Century
From Everand
The World Is Flat 3.0: A Brief History of the Twenty-first Century
Bad Feminist: Essays
From Everand
Bad Feminist: Essays
The Outsider: A Novel
From Everand
The Outsider: A Novel
The Woman in Cabin 10
From Everand
The Woman in Cabin 10
A Tree Grows in Brooklyn
From Everand
A Tree Grows in Brooklyn
The Sympathizer: A Novel (Pulitzer Prize for Fiction)
From Everand
The Sympathizer: A Novel (Pulitzer Prize for Fiction)
A Heartbreaking Work Of Staggering Genius: A Memoir Based on a True Story
From Everand
A Heartbreaking Work Of Staggering Genius: A Memoir Based on a True Story
Team of Rivals: The Political Genius of Abraham Lincoln
From Everand
Team of Rivals: The Political Genius of Abraham Lincoln
Wolf Hall: A Novel
From Everand
Wolf Hall: A Novel
On Fire: The (Burning) Case for a Green New Deal
From Everand
On Fire: The (Burning) Case for a Green New Deal
Fear: Trump in the White House
From Everand
Fear: Trump in the White House
Manhattan Beach: A Novel
From Everand
Manhattan Beach: A Novel
Rise of ISIS: A Threat We Can't Ignore
From Everand
Rise of ISIS: A Threat We Can't Ignore
John Adams
From Everand
John Adams
The Light Between Oceans: A Novel
From Everand
The Light Between Oceans: A Novel
60 ATL Tcil - Sheet8
PDF
60 ATL Tcil - Sheet8
MCS213 SOFTWARE ENGINEERING Compressed
PDF
MCS213 SOFTWARE ENGINEERING Compressed
MCS215 SECURITY&CYBERLAWS Compressed
PDF
MCS215 SECURITY&CYBERLAWS Compressed
Adobe Scan 21-Nov-2024
PDF
Adobe Scan 21-Nov-2024
XIIInfo Pract 37
PDF
XIIInfo Pract 37
Class 12 CS Practice Paper 2024-25
PDF
Class 12 CS Practice Paper 2024-25
The Unwinding: An Inner History of the New America
From Everand
The Unwinding: An Inner History of the New America
Little Women
From Everand
Little Women
The Constant Gardener: A Novel
From Everand
The Constant Gardener: A Novel