OrderBy 记录 ASC 分两列
OrderBy record ASC in two columns
我正在尝试在 windows 应用程序中以我的专栏大声形式进行 OrderBy。我尝试使用此代码:
using (SqlCommand sqlcomm = new SqlCommand("SELECT * FROM remaining WHERE username=@username and status=@status and company_status=@company_status ORDER BY call_case ASC , Payment_Status ASC", sqlconn))
这是正确的做法吗?
我要找的是OrderBy (call_case) ASC,当call_case= (2-Answer) OrderBy (Payment_Status) ASC .
( call_case ), ( Payment_Status )
null , null
1-No Answer , null
2-answer , 1-Promise Payment
2-answer , 2-Have Problem
2-answer , 3-Reject Payment
3- not Exist , null
i have a note it my be help the text start with number like 1-No Answer , 2-answer , 3- not Exist
您可以使用 CASE
表达式和 ORDER BY
like
SELECT * FROM remaining
WHERE username=@username
and status=@status
and company_status=@company_status
ORDER BY
case when call_case='Answer' then 0 else 1 end ASC,
Payment_Status ASC
我正在尝试在 windows 应用程序中以我的专栏大声形式进行 OrderBy。我尝试使用此代码:
using (SqlCommand sqlcomm = new SqlCommand("SELECT * FROM remaining WHERE username=@username and status=@status and company_status=@company_status ORDER BY call_case ASC , Payment_Status ASC", sqlconn))
这是正确的做法吗?
我要找的是OrderBy (call_case) ASC,当call_case= (2-Answer) OrderBy (Payment_Status) ASC .
( call_case ), ( Payment_Status )
null , null
1-No Answer , null
2-answer , 1-Promise Payment
2-answer , 2-Have Problem
2-answer , 3-Reject Payment
3- not Exist , null
i have a note it my be help the text start with number like 1-No Answer , 2-answer , 3- not Exist
您可以使用 CASE
表达式和 ORDER BY
like
SELECT * FROM remaining
WHERE username=@username
and status=@status
and company_status=@company_status
ORDER BY
case when call_case='Answer' then 0 else 1 end ASC,
Payment_Status ASC