Skip to main content
Inspiring
December 3, 2008
Question

Using CFGRID with logic

  • December 3, 2008
  • 1 reply
  • 306 views
I am using CS3 and ColdFusion 8.

I have a query that populates a cfgrid with no problems. However, I would like to add an extra column. The extra column will be populated according to data elements in the previous columns. For example, five students take a test. I want the Grade Letter column, which is populated with ??, to contain logic that will display A,B,C,D, or F according to their respective Grade Number.

Any ideas on how to do this?

    This topic has been closed for replies.

    1 reply

    Inspiring
    December 4, 2008
    use your db's control flow functions (i.e. CASE-WHEN-THEN-ELSE-END, IF,
    etc) to add another column to your query with value based on gade_number
    column.

    example (mysql syntax - your db's syntax may be different!):

    SELECT name, grade_number, (CASE grade_name WHEN 1 THEN 'A' WHEN 2 THAN
    'B' WHEN 3 THEN 'C' WHEN 4 THEN 'D' WHEN 5 THEN 'E' ELSE 'N/A' END) AS
    grade_letter
    FROM ...

    hth

    Azadi Saryev
    Sabai-dee.com
    http://www.sabai-dee.com/