Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如何使用sql查询根据设置值(状态= 1)选择前3行,其余应按降序选择..
假设我有表 'table1' 有 '9' 行,例如 sn 和状态 1->0 ,2->0, 3->1, 4->0, 5->1, 6->0, 7-> 0, 8->0, 9->1
我需要前三个应该根据状态“1”,其余的“6”行正常...输出将是 3 5 9 前三个根据状态 1 来,其他是 1 2 4 6 7 8 o/p 3 5 9 1 2 4 6 7 8
Select sn,status From myTable Order By status DESC,sn