CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Aug 2011
    Posts
    1

    sql computed column formula syntax help

    i got two columns in mysql 2005

    Grade and Remarks

    i need to do is.. when i input integers in grade column

    1,1.25,1.50,1.75,2,2.25,2.50,2.75,3

    then Remarks will show PASSED

    and when Grade is 4 up

    remarks will show FAILED

    (OPTIONAL)
    if Grade is null

    then Remarks will show UNKOWN

    this is my code but it doesnt works on sql computed column formula

    IIF(Grade >=4, 'Failed', IIF(Grade IN (1,1.25,1.50,1.75,2,2.25,2.50,2.75,3), 'PASSED','UNKNOWN'))



    can anyone revise my code into.. sql formula code?? thanks

  2. #2
    Join Date
    Sep 2000
    Location
    FL
    Posts
    1,452

    Re: sql computed column formula syntax help

    Well, this is more of a MySQL question and I am assuming you want an SQL query to do it for you but...

    SELECT IF(GRADE IS NULL, 'UNKNOWN', IF(GRADE>=4,'FAILED','PASSED')) AS Grade, Remarks
    FROM MyTable.

    Now if this is homework, and you need this done in VB.Net code, then show us your code so we can see what you have.

Tags for this Thread

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

Featured