followgasra.blogg.se

How to sum a column in excel with certain number
How to sum a column in excel with certain number




how to sum a column in excel with certain number

WHEN sum(social + math + science ) >=200 THEN 'B' Read more on CASE WHEN THEN statement here.ĬASE WHEN sum(social + math + science ) >= 225 THEN 'A' Here we will check total mark against set marks for different levels of grade and allot Grade accordingly. MySQL Case query executes the statement based on the matching condition. We can display grade of the student by using CASE statement in our Query. Show Grade based on the total mark ( using CASE statement ) Sum(social)+sum(math)+sum(science) from student_sum Note that we have to maintain same number of columns while using UNION query. Like we do in MS Excel we can display sum of all columns and the sum of all total subject marks by using UNION. LEAST(social,science,math) as min FROM student_sum idĭisplaying sum of all columns at last row We can list starting from highest mark to lowest mark by using Order By Query.įrom student_sum GROUP BY id ORDER BY Total DESC Displaying highest & lowest mark in all subjects of each student SELECT id,name,GREATEST(social,science,math) as max, Listing all columns along with aggregate functions like sum(), max() using over() with partition → Displaying from Highest to lowest SELECT id,name,class, social, math, science, Note that id is unique value column in our table. Now we will try to display all marks and sum of them for each student by using group by. Query to display percentage value using 2 decimal places.įORMAT((( social + science + math)/(95*3) * 100),2) AS percentageįROM `student_sum` Sum of the row data of each record The above percentage data is having four decimal places, we can format these numbers by using ROUND Sql command. (( social + science + math)/(95*3) * 100) AS percentage SELECT id, name, class,( social + science + math) as Total, SELECT name, (( social + science + math)/(95*3) * 100) AS percentageįROM `student_sum` Displaying Total Mark with Percentageīoth total mark and percentage we can display like this So to get the percentage mark of each student we have to multiply 95 with 3 ( for three subjects ) and then divide that from the total and multiply with 100 here is the query.

#How to sum a column in excel with certain number full

Let us assume the full mark in each subject is 95. We can add various other sql commands like where clause etc. SELECT sum(social + math + science ) as total So the sum is to be collected in all three columns.

how to sum a column in excel with certain number

Now we will try to get sum of marks of all students in all subjects. Related Tutorial MySQL SUM MySQL Max MySQL Min MySQL AvgĪs you can see the above sum is sum of marks of each student.






How to sum a column in excel with certain number