c# - 两列中的 OrderBy 记录 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
我有一个注释,我可以帮助文本以数字开头,例如 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
推荐阅读
- ethereum - Web3 getTransaction returns null even in geth same
- storage - AnyLogic:将两个代理同时移动到托盘架中
- python - Nested custom directives in sphinx
- solana - 我想知道导致 solana 传输错误
- flutter - How to make an API request with selectableDayPredicate of flutter datePicker
- python - pandas如何将上组的部分数据添加到下组的开头
- java - how to receive data in one activity in communication with a bluetooth module using service
- excel - How to test for instance of httpheader using vba
- ios - Print to printer via Bluetooth(non Airprint) in iOS?
- angular - Angular
is displaying the parent twice