Search code examples
mysqlsqlcasedeclare

i cant declaring in query


@a =( CASE WHEN amount IS NOT NULL THEN amount1 
      WHEN percentage IS NOT NULL THEN sco.amount *  1 + (percentage / 100) END) AS data1

without @a i am getting result but with @a i am not getting result


Solution

  • Try like this below , you were missing :

    @a :=( CASE WHEN amount IS NOT NULL THEN amount1 
              WHEN percentage IS NOT NULL THEN sco.amount *  1 + (percentage / 100) END) AS data1