- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Find the percentage of a student on basis of marks and add percent sign (%) to the result in SQL
Let us first create a table −
mysql> create table DemoTable ( Marks int ); Query OK, 0 rows affected (0.62 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable values(88); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable values(65); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable values(98); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable values(45); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable values(67); Query OK, 1 row affected (0.33 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable;
This will produce the following output −
+-------+ | Marks | +-------+ | 88 | | 65 | | 98 | | 45 | | 67 | +-------+ 5 rows in set (0.00 sec)
Following is the query to calculate percentage of the student in the basis of marks in 5 subjects. The result would be in percentage; therefore, we will also add percent sign (%) to the calculation −
mysql> select concat(round(SUM(Marks)*100/500),'%') from DemoTable;
This will produce the following output −
+---------------------------------------+ | concat(round(SUM(Marks)*100/500),'%') | +---------------------------------------+ | 73% | +---------------------------------------+ 1 row in set (0.00 sec)
- Related Articles
- Display the student marks in a single column on the basis of subject in MySQL?
- Set custom messages on the basis of a column with student marks in MySQL
- The percentage of marks obtained by a student in monthly unit tests are given below:Find the probability that the student gets more than $70 %$ marks."
- Determining rank on basis of marks in JavaScript
- In an examination , a student has to score 40%marks to pass. He gets 40 marks and fail by 40 marks. Find the maximum number of marks
- Group the marks of a particular student from a table and display total marks in a separate column for each student?
- The marks obtained by 10 students in a test are $60,72,70,64,56,52,71,54,62,59$. Find the mean marks of the students. Find the mean marks of the students if 6 extra marks are given to each student.
- MySQL query to ORDER BY records on the basis of modulus result
- Find percentage from marks in MySQL
- Add a percentage (%) sign at the end to each value while using MySQL SELECT statement
- What sign (+ve or −ve) has been given to the following on the basis of Cartesian Sign Convention?(a) Height of a real image.(b) Height of a virtual image.
- Find out if a varchar contains a percent sign in MySQL?
- Add a new column and set values in it on the basis of conditions in MySQL?
- A shopkeeper marks an article which is 60% more than the cp and allows a discount of 25% on it. Find his gain percent
- How to sort MySQL output on the basis of the column which is not in the result set?

Advertisements