Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Searching and renaming values

Author  Topic 

layst
Starting Member

3 Posts

Posted - 2011-04-26 : 01:09:07
I want to make a statement that searches of an instance of 0 in a column, and I would like to be able to cahnge the output so instead of the 0 I have 'ZERO'.

As it is I have 3 tables, as you can see in my SQL that are all linked bu different fields.

SELECT SUBJECT_OFFERING.CourseID, STUDENT.StudentName, STUDENT.StudentState, COURSE_OFFERING.CourseStartDate, COURSE_OFFERING.ClassEndDate, RESULTS.GRADE

FROM STUDENT, RESULTS, SUBJECT_OFFERING, COURSE_OFFERING

WHERE STUDENT.StudentID = RESULTS.StudentID AND RESULTS.SubjectID = SUBJECT_OFFERING.SubjectID AND SUBJECT_OFFERING.CourseID = COURSE_OFFERING.CourseID AND RESULTS.GRADE = 'RO'
IM WANTING TO PUT SOMETHING at the end like IF RESULTS.Assignment1Mark = 0 then output AS 'ZERO'



;
I don't want to change the name of the column, but just the output that i retrieve.

Thanks if anyone can offer me some incite.

vaibhavktiwari83
Aged Yak Warrior

843 Posts

Posted - 2011-04-26 : 05:14:55
Are you looking for this -

SELECT SUBJECT_OFFERING.CourseID, STUDENT.StudentName, STUDENT.StudentState, COURSE_OFFERING.CourseStartDate, COURSE_OFFERING.ClassEndDate, RESULTS.GRADE,
CASE WHEN RESULTS.Assignment1Mark = 0 then 'ZERO' END AS Assignment1Mark
FROM STUDENT, RESULTS, SUBJECT_OFFERING, COURSE_OFFERING
WHERE STUDENT.StudentID = RESULTS.StudentID AND RESULTS.SubjectID = SUBJECT_OFFERING.SubjectID AND SUBJECT_OFFERING.CourseID = COURSE_OFFERING.CourseID AND RESULTS.GRADE = 'RO'


Vaibhav T

If I cant go back, I want to go fast...
Go to Top of Page
   

- Advertisement -