Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6239123
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T11:20:18+00:00 2026-05-24T11:20:18+00:00

I am generating an SQL query: SELECT * FROM ToDoList WHERE ws_status <> ‘Completed’

  • 0

I am generating an SQL query:

SELECT * FROM ToDoList 
WHERE ws_status <> 'Completed' 
AND (user_id= 'TESTUSR' OR ww_cover='TESTUSR' 
OR (ws_status = 'Orphan' AND wwt_workgroupid IN (108))) 
**ORDER BY psc_alt_code ASC**

And I need to list all results with wi_urgent set to ‘Y’ and order them by date Desc *first and then list all other results ordered by psc_alt_code descending* so I thought something like this would suffice:

ORDER BY (wi_urgent = 'Y') DESC, psc_alt_code ASC

I am getting SqlClient.SqlException: Incorrect syntax near '=' error when trying to run that query. Please note that I am querying an SQL View if that makes a difference?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T11:20:19+00:00Added an answer on May 24, 2026 at 11:20 am

    You can use a case expression in the order by

    SELECT * FROM ToDoList 
    WHERE ws_status <> 'Completed' 
    AND (user_id= 'TESTUSR' OR ww_cover='TESTUSR' 
    OR (ws_status = 'Orphan' AND wwt_workgroupid IN (108))) 
    ORDER BY CASE WHEN wi_urgent = 'Y' THEN 0 ELSE 1 END ASC
    ,psc_alt_code 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm getting a SQL query from NH, and it's generating a column that does
I'm currently generating SQL insert statements from more than one tables, and in the
I'm having an issue getting a COUNT() from a SQL query using Zend_Db_Table_Select, and
This Linq to SQL query ... Return (From t In Db.Concessions Where t.Country =
I'm generating T-SQL SELECT statements for tables for which I have no data type
Facing problem for generating SQL Server Query In the Following query dynamic conditions are
Hibernate is generating invalid SQL for a particular criteria query. I can manually fix
Does anyone have a technique for generating SQL table create (and data insert) commands
Do you have any tricks for generating SQL statements, mainly INSERTs, in Excel for
I am generating a reports using SQL Reporting services 2005. I need to protect

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.