Results 1 to 3 of 3

Thread: CASE WHEN problem

  1. #1

    Thread Starter
    PowerPoster Simply Me's Avatar
    Join Date
    Aug 2003
    Posts
    2,748

    CASE WHEN problem

    Hi!

    I am trying to get the General Average of the students and I want to have the results displayed in column GenAve, GenAve2 and so on... I tried the code below and its working but I dont know how will I make the results be displayed in GenAve and GenAve respectively and also, how do I make the result 77.257000 to display as 77.257?
    Code:
    select IDNO,LastName, FirstName, MI,YearLevel,SectionName,GenAve,GenAve2,
    CASE
    --First Grading
    WHEN YearLevel='LC7' and SectionName='FirstYearSection1' THEN 
     	Round((((Filipino * 1.2) + (English * 1.5) + (Math * 1.5) + (Science * 1.8) + ([Araling Panlipunan] * 1.2) +
    		(TLEComputer * 1.2) + (MAPEH * 1.2) + (CLEESP * 0.9) + ([Earth Science] * 1))/11.5),3)
    
    --Second Grading
    WHEN YearLevel='LC7' and SectionName='FirstYearSection1' THEN 
     	Round((((Filipino2 * 1.2) + (English2 * 1.5) + (Math2 * 1.5) + (Science2 * 1.8) + ([Araling Panlipunan2] * 1.2) +
    		(TLEComputer2 * 1.2) + (MAPEH2 * 1.2) + (CLEESP2 * 0.9) + ([Earth Science2] * 1))/11.5),3)
    END
    To give is always to be NOBLE...
    To received is always to be BLESSED....
    Each day strive to be NOBLE
    Each day strive to be BLESSED

    If this post has helped you. Please take time to rate it.

    >=|+|=< Simply Me >=|+|=<

    ----------------------------------------
    Connection Strings | Number Only in Textbox | Splash Screen with Progress Bar | Printing to 1/2 of perforated bond paper |
    Freeze 2005 DataGridView Column

  2. #2

    Thread Starter
    PowerPoster Simply Me's Avatar
    Join Date
    Aug 2003
    Posts
    2,748

    Re: CASE WHEN problem

    by the way I just updating my table. How do I use UPDATE in the above code?
    To give is always to be NOBLE...
    To received is always to be BLESSED....
    Each day strive to be NOBLE
    Each day strive to be BLESSED

    If this post has helped you. Please take time to rate it.

    >=|+|=< Simply Me >=|+|=<

    ----------------------------------------
    Connection Strings | Number Only in Textbox | Splash Screen with Progress Bar | Printing to 1/2 of perforated bond paper |
    Freeze 2005 DataGridView Column

  3. #3
    Super Moderator FunkyDexter's Avatar
    Join Date
    Apr 2005
    Location
    An obscure body in the SK system. The inhabitants call it Earth
    Posts
    7,902

    Re: CASE WHEN problem

    Your question is very unclear but I think you're after something like this:-
    select IDNO,LastName, FirstName, MI,YearLevel,SectionName,
    Round((((Filipino * 1.2) + (English * 1.5) + (Math * 1.5) + (Science * 1.8) + ([Araling Panlipunan] * 1.2) + (TLEComputer * 1.2) + (MAPEH * 1.2) + (CLEESP * 0.9) + ([Earth Science] * 1))/11.5),3) as GenAve,
    Round((((Filipino2 * 1.2) + (English2 * 1.5) + (Math2 * 1.5) + (Science2 * 1.8) + ([Araling Panlipunan2] * 1.2) + (TLEComputer2 * 1.2) + (MAPEH2 * 1.2) + (CLEESP2 * 0.9) + ([Earth Science2] * 1))/11.5),3) as GenAve2

    If that's not what you're after then I think you're going have to be MUCH clearer in your question. Show us some data and the desired result.
    The best argument against democracy is a five minute conversation with the average voter - Winston Churchill

    Hadoop actually sounds more like the way they greet each other in Yorkshire - Inferrd

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width