Results 1 to 11 of 11

Thread: Computing Grade

  1. #1
    PowerPoster Simply Me's Avatar
    Join Date
    Aug 03
    Posts
    2,687

    Computing Grade

    Hi!

    I am using SP and part of which is to get the average of a certain subject...I am doing it like
    Code:
    UPDATE tblgrade
    SET [MAPEH] =((MUSIC * .25) + (ARTS * .25) + (PE * .25) + (HEALTH * .25))
    FROM tblenrol
    WHERE tblGrade.IDNO = tblenrol.IDNO
    AND tblGrade.yearlevel = tblenrol.yearlevel
    AND tblenrol.SubjectName like 'MUSIC%'
    AND tblenrol.SubjectName like 'ARTS%'
    AND tblenrol.SubjectName like 'PE%'
    AND tblenrol.SubjectName like 'HEALTH%'
    but I am not getting any result at all so I tried doing it like
    Code:
    UPDATE tblgrade
    SET [MAPEH] =((tblenrol.SubjectName like 'MUSIC%' * .25) + (ARTS * .25) + (PE * .25) + (HEALTH * .25))
    FROM tblenrol
    WHERE tblGrade.IDNO = tblenrol.IDNO
    AND tblGrade.yearlevel = tblenrol.yearlevel
    AND tblenrol.SubjectName like 'MUSIC%'
    AND tblenrol.SubjectName like 'ARTS%'
    AND tblenrol.SubjectName like 'PE%'
    AND tblenrol.SubjectName like 'HEALTH%'
    but still its not correct. it's a syntax error.

    Music, Arts, PE, and Health are subjects in my other table. I had them converted as fields in the table where I would like to have the Final grade to appear.
    here's part of my SP
    Code:
    CREATE TABLE [dbo].[tblGrade](
    	[IDNo] [nvarchar](10) NOT NULL,
    	[LastName] [nvarchar](50) NULL,
    	[FirstName] [nvarchar](50) NULL,
    	[MI] [nvarchar](50) NULL,
    	[Reading] [numeric](5, 0) NULL,
    	[Language] [numeric](5, 0) NULL,
    	[English] [numeric](5, 0) NULL,
    	[Math] [numeric](5, 0) NULL,
    	[Music] [numeric](5, 0) NULL,
    	[Arts] [numeric](5, 0) NULL,
    	[PE] [numeric](5, 0) NULL,
    	[Health] [numeric](5, 0) NULL,
    	[MAPEH] [numeric](5, 0) NULL,
    I hope, I explained it clearly. Anyone can help me please?
    Last edited by Simply Me; Oct 28th, 2012 at 02:10 AM. Reason: Wrong Title
    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
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 02
    Location
    Bristol, UK
    Posts
    35,624

    Re: Getting Average

    There is no way you could get any records, just think about what this part means:
    AND tblenrol.SubjectName like 'MUSIC%'
    AND tblenrol.SubjectName like 'ARTS%'
    How can SubjectName start with two different things at the same time?

  3. #3
    PowerPoster Simply Me's Avatar
    Join Date
    Aug 03
    Posts
    2,687

    Re: Getting Average

    I have subjectname like Music1, Music2, Arts1, Arts2 etc...
    My tblenrol:
    Code:
    Name 	SubjectName   Quiz	Exam	FG
    John Doe	Music	             85	85	85
    	        Arts	             74	76	75
    	        PE	             88	87	88
    	        Health	     74	76	75
    MytblGrade should look like
    Name Music Arts PE Health MAPEH
    John Doe 85 75 88 75 81

    I get the MAPEH grade by getting 25% of Music, Arts, PE and Health respectively.
    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

  4. #4
    PowerPoster Simply Me's Avatar
    Join Date
    Aug 03
    Posts
    2,687

    Re: Getting Average

    I have subjectname like Music1, Music2, Arts1, Arts2 etc...

    Please see attachment on how my tables should look like. I compute MAPEH Grade by getting 25% of Music, Arts, PE and Health.
    Thank you.
    Attached Images Attached Images  
    Last edited by Simply Me; Oct 28th, 2012 at 01:45 AM.
    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

  5. #5
    PowerPoster Simply Me's Avatar
    Join Date
    Aug 03
    Posts
    2,687

    Re: Computing Grade

    I saw this code somewhere but I don't quite well understand it...
    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

  6. #6
    PowerPoster Simply Me's Avatar
    Join Date
    Aug 03
    Posts
    2,687

    Re: Computing Grade

    I saw this code somewhere but I don't quite well understand it...
    Code:
    select (select count(*) from locations where url is null) as unprocessed, (select count(*) from locations where url is not null) as processed, (((select processed / (unprocessed + processed)) * 100)) as "% complete";
    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

  7. #7
    PowerPoster Simply Me's Avatar
    Join Date
    Aug 03
    Posts
    2,687

    Re: Computing Grade

    I tried this out and it did not work..
    Code:
    Select (Select count(*) from tblenrolk12 
    WHERE tblGradeK12.IDNO = tblenrolK12.IDNO
    AND tblGradeK12.yearlevel = tblenrolK12.yearlevel
    AND tblenrolK12.SubjectName like 'MUSIC%'
    AND tblenrolK12.SubjectName like 'ARTS%'
    AND tblenrolK12.SubjectName like 'PE%') as MAPEH
    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

  8. #8
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 02
    Location
    Bristol, UK
    Posts
    35,624

    Re: Computing Grade

    Of course it didn't, see post #2.

  9. #9
    PowerPoster Simply Me's Avatar
    Join Date
    Aug 03
    Posts
    2,687

    Re: Computing Grade

    I understand now what you mean in post #2..How will I get then the MAPEH grade when I have 4 subjects (Music, Arts, PE, Health) where I will get 25% from each subject? Any code where I get started with?
    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

  10. #10
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 02
    Location
    Bristol, UK
    Posts
    35,624

    Re: Computing Grade

    When you get a response, you shouldn't reply 5 times before understanding it. Before you post again you should work it out, and act on it appropriately.... and if you can't work it out yourself, your first reply after it should be to ask questions to help you understand it. Just ignoring it as you did is rather rude.

    I for one do not see the point in attempting to help somebody who acts the way you did (especially someone who has thousands of posts), so I'm out of here.

  11. #11
    PowerPoster Simply Me's Avatar
    Join Date
    Aug 03
    Posts
    2,687

    Re: Computing Grade

    I'm sorry but I don't mean to be rude sir...at first I just didn't get what you meant in your post #2 I did reply in post #3 where I answered "I have subjectname like Music1, Music2, Arts1, Arts2 etc..." that was my answer because I misunderstood what you meant by "How can SubjectName start with two different things at the same time?"
    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

Posting Permissions

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