• If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Announcement

Collapse
No announcement yet.

Case statement not allowed in order by in data source

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Case statement not allowed in order by in data source

    I have a data source where I always want the '*DEFAULT' user to be the first row in the grid and then the rest to be alphabetical. I can accomplish this using a case statement in SQL. When I try to add this SQL to Valence, I get an error saying "Order by can only contain column or alias names." Is there another way that I can do this?

    Valence Order By Screenshot 2025-05-08 095057.jpg

  • #2
    Create a derived column and then reference the column in the ORDER BY clause

    For Example:
    Code:
    SELECT
      cusno,
      cname,
      caddr1,
      ccity,
      cstate,
      czip,
    CASE
      cname
        WHEN 'CNX Corporation'
          THEN 1
        ELSE 99
    END AS iscnx
    FROM
      democmast
    ORDER BY
      iscnx

    Comment

    Working...
    X