Click here to Skip to main content
15,897,187 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
hello sir i want change mark to garde ,i have two table Grade and Student Marks table.plz suggest me sql query ,how to get it
my grade table is
CSS
id  Grade   maxmark     minmark
4   A        5.00        4.10        

5   B       4.00        3.10        
6   C       3.00        2.10       
7   D       2.00        1.10      
8   E       1.00        0.00          </pre>


and student marks table

CSS
MarksId   StudentId                     Marks
7         3415                           4     
8         3415                           2      
9         3415                           3       



and i want result mark convert into grade
for example
MarksId StudentId grade
7 3415 B (grade will be B because mark 4 between B Grade in Grade table)
Posted
Updated 20-Aug-14 21:28pm
v2

Assuming these are SQL tables, and you are trying to do it in SQL:
SQL
SELECT sm.MarksId, sm.StudentId, g.Grade AS Grade FROM StudentMarks sm
JOIN Grade g ON sm.Marks <= g.MaxMark AND sm.Marks >= g.MinMark


[edit]
Or better:
SQL
SELECT sm.MarksId, sm.StudentId, g.Grade AS Grade FROM StudentMarks sm
JOIN Grade g ON sm.Marks BETWEEN g.MinMark AND g.MaxMark

[/edit]
 
Share this answer
 
v2
Comments
manvendra patel 21-Aug-14 4:09am    
thanks lot its working
manvendra patel 21-Aug-14 4:12am    
second query going fine
OriginalGriff 21-Aug-14 4:14am    
You're welcome!
use below query
SQL
select distinct markid,studid,grade from marks
join grades1 ON marks.marks between MaxMArk and MinMark
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900