2

I am getting the error "Incorrect parameters in the call to native function 'CONCAT': on the query below:

SELECT
  *,
  GROUP_CONCAT(
    CASE
      WHEN `REASONORINSTRUCTIONCODE` = 'R'
      THEN CONCAT(
        "name-",
        `USERWHOENTEREDTHISLINE`,
        ",reason-",
        RTRIM(
          `REASONSORSHIPPINGINSTRUCTIONS`
        )
      END,
      ", "
    )
  ) AS reason,
  GROUP_CONCAT(
    CASE
      WHEN [ `REASONORINSTRUCTIONCODE` ] = 'S'
      THEN CONCAT(
        "name-",
        `USERWHOENTEREDTHISLINE`,
        ",shipping instruction-",
        RTRIM(
          `REASONSORSHIPPINGINSTRUCTIONS`
        )
      END,
      ", "
    )
  ) AS shipping instruction
FROM
  TABLE
GROUP BY `PICKUP_NO`

1 Answer 1

2

You have several issues with your query. First, you're not closing your CONCAT with an end ), next your AS shipping instruction cannot contain a space. Next, you have [REASONORINSTRUCTIONCODE], remove the []

Take a look at the formatted query below:

SELECT
  *,
  GROUP_CONCAT(
    CASE
      WHEN `REASONORINSTRUCTIONCODE` = 'R'
      THEN CONCAT(
        "name-",
        `USERWHOENTEREDTHISLINE`,
        ",reason-",
        RTRIM(
          `REASONSORSHIPPINGINSTRUCTIONS`
        ))
      END,
      ", "
    )
   AS reason,
  GROUP_CONCAT(
    CASE
      WHEN `REASONORINSTRUCTIONCODE` = 'S'
      THEN CONCAT(
        "name-",
        `USERWHOENTEREDTHISLINE`,
        ",shipping instruction-",
        RTRIM(
          `REASONSORSHIPPINGINSTRUCTIONS`
        ))
      END,
      ", "
    )
   AS shipping_instruction
FROM
  `TABLE`
GROUP BY `PICKUP_NO`
Sign up to request clarification or add additional context in comments.

1 Comment

@user3369545 you're quite welcome, glad I could help

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.