Click here to Skip to main content
15,889,825 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Student table as follows

Name Rollno subject marks

A 1 ENG 50
B 2 TAM 60


Report table as follows

Rollno marks

1 50
2 60

in the above two table if the marks column is matched. then add the new column called result.

select s.name,s.rollno,s.subject from student s,Report r where s.Rollno=r.rollno and s.marks=r.marks

when i run the above query, output as follows

Name Rollno Subject Marks

A 1 ENG 50
B 2 TAM 60


But i want the output as follows

Name Rollno Subject Marks Result

A 1 ENG 50 Pass
B 2 TAM 60 Pass

from the above query how
Posted

try this

SQL
select s.name,s.rollno,s.subject,case when s.marks<30 then 'PASS' else 'FAIL' End from student s,Report r where s.Rollno=r.rollno and s.marks=r.marks
 
Share this answer
 
Assuming 50 and above is 'PASS' else 'FAIL':
SQL
select name, rollno, subject, marks,
case when
   marks >=50 then 'PASS'
else
   'FAIL'
end
from student s where exists
(
select * from report r
  where r.rollno = s.rollno and r.marks = s.marks
)
 
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