Answers for "how to write orderby and where clause in sql"

SQL
1

sql order by where condition

SELECT ProcductCode AS Id, ProductPrice AS Price
FROM Products WITH (NOLOCK)
WHERE ProductCode IN ('efg', 'abc', 'xyz')
ORDER BY (CASE WHEN ProductCode = 'efg' THEN 1
               WHEN ProductCode = 'abc' THEN 2
               WHEN ProductCode = 'xyz' THEN 3
               ELSE 4  -- in case you change the `where`, put them last
          END);
Posted by: Guest on September-02-2020

Code answers related to "how to write orderby and where clause in sql"

Code answers related to "SQL"

Browse Popular Code Answers by Language