Recent PostsRecent Posts Popular TopicsPopular Topics
 Home Search Members Calendar Who's On

 Query help Rate Topic Display Mode Topic Options
Author
 Message
 Posted Wednesday, July 03, 2013 10:33 AM
 Grasshopper Group: General Forum Members Last Login: Friday, December 06, 2013 12:29 PM Points: 22, Visits: 287
 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 !!
Post #1470158
 Posted Wednesday, July 03, 2013 10:53 AM
 Grasshopper Group: General Forum Members Last Login: Friday, December 06, 2013 12:29 PM Points: 22, Visits: 287
 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?
Post #1470164
 Posted Wednesday, July 03, 2013 1:45 PM
 Grasshopper Group: General Forum Members Last Login: Friday, December 06, 2013 12:29 PM Points: 22, Visits: 287
 any help?
Post #1470211
 Posted Wednesday, July 03, 2013 2:20 PM
 SSCommitted Group: General Forum Members Last Login: Today @ 5:35 PM Points: 1,880, Visits: 4,148
 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.Please don't trust me, test the solutions I give you before using them.Forum Etiquette: How to post data/code on a forum to get the best help
Post #1470226
 Posted Wednesday, July 03, 2013 2:44 PM
 Grasshopper Group: General Forum Members Last Login: Friday, December 06, 2013 12:29 PM Points: 22, Visits: 287
 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 !!
Post #1470236
 Posted Thursday, July 04, 2013 3:22 AM
 SSCrazy Group: General Forum Members Last Login: Wednesday, November 20, 2013 10:00 AM Points: 2,719, Visits: 4,724
 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!"(So many miracle inventions provided by MS to us...)How to post your question to get the best and quick help
Post #1470356

 Permissions