## Query help

 Author Message Keejli69 Mr or Mrs. 500 Group: General Forum Members Points: 537 Visits: 796 Eugene Elutin (7/3/2013)like this:SELECT q.Course_Code, 6-res.[4a] as [4a],6-res.[4b] as [4b], 6-res.[4c] as [4c], 6-res.[5a] as ,res.[5b],res.[5c],res.[6a],res.[6b],res.[6c],res.[7a],res.[7b],res.[7c],res.[7d],res.[7e] as convertedFROMThe above willnot compile as has quite few errors. You should be more accurate.Basically, in order to convert existing returned values as you requested, these values hould be subtrected out of 6, as: 6 - 5 = 16 - 4 = 26 - 3 = 36 - 2 = 46 - 1 = 5Now, if you use the expression when retunring columns, they will need to be given aliases, therefore: 6-res.[4a] as [4a],6-res.[4b] as [4b],...etc. Thanks Eugene !! I appreciate your help !! Keejli69 Mr or Mrs. 500 Group: General Forum Members Points: 537 Visits: 796 elee1969 (7/3/2013)Eugene Elutin (7/3/2013)like this:SELECT q.Course_Code, 6-res.[4a] as [4a],6-res.[4b] as [4b], 6-res.[4c] as [4c], 6-res.[5a] as ,res.[5b],res.[5c],res.[6a],res.[6b],res.[6c],res.[7a],res.[7b],res.[7c],res.[7d],res.[7e] as convertedFROMThe above willnot compile as has quite few errors. You should be more accurate.Basically, in order to convert existing returned values as you requested, these values hould be subtrected out of 6, as: 6 - 5 = 16 - 4 = 26 - 3 = 36 - 2 = 46 - 1 = 5Now, if you use the expression when retunring columns, they will need to be given aliases, therefore: 6-res.[4a] as [4a],6-res.[4b] as [4b],...etc. Thanks Eugene !! I appreciate your help !!Right now 6 - 0 returns 6. What if i want to keep it as 0? Keejli69 Mr or Mrs. 500 Group: General Forum Members Points: 537 Visits: 796 any help? Luis Cazares SSC Guru Group: General Forum Members Points: 95019 Visits: 21186 You can use a CASE statement.`SELECT q.Course_Code, CASE WHEN res.[4a] = 0 THEN 0 ELSE 6-res.[4a] END as [4a],...` Luis C.General Disclaimer:Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?How to post data/code on a forum to get the best help: Option 1 / Option 2 Keejli69 Mr or Mrs. 500 Group: General Forum Members Points: 537 Visits: 796 Luis Cazares (7/3/2013)You can use a CASE statement.`SELECT q.Course_Code, CASE WHEN res.[4a] = 0 THEN 0 ELSE 6-res.[4a] END as [4a],...`ah thanks luis. :-) i knew it would be the CASE statement but didn't know how i would work it into the Select section. Thanks again !! Eugene Elutin SSC-Dedicated Group: General Forum Members Points: 31700 Visits: 5478 elee1969 (7/3/2013)Luis Cazares (7/3/2013)You can use a CASE statement.`SELECT q.Course_Code, CASE WHEN res.[4a] = 0 THEN 0 ELSE 6-res.[4a] END as [4a],...`ah thanks luis. :-) i knew it would be the CASE statement but didn't know how i would work it into the Select section. Thanks again !!or:`SELECT q.Course_Code, 6 - ISNULL(NULLIF(res.[4a],0),6) as [4a],` _____________________________________________"The only true wisdom is in knowing you know nothing""O skol'ko nam otkrytiy chudnyh prevnosit microsofta duh!":-D(So many miracle inventions provided by MS to us...)How to post your question to get the best and quick help