2 edited body; edited title
source | link

MSSQL SQL Server Order SELECT List with condition

I want order the select list with condition. For example; I have t1 table and it has 3 columns and 6 rows

Table t1:   
+----+---+---+
| id | x | y |
+----+---+---+
| 1  | a | 1 |
| 2  | b | 3 |
| 3  | c | 2 |
| 4  | d | 2 |
| 5  | e | 1 |
| 6  | f | 3 |
+----+---+---+

Ordering the select list without condition, that select query is easy:
SELECT y FROM t1 ORDER BY y
result: 1,1,2,2,3,3
SELECT y FROM t1 ORDER BY y DESC
result: 3,3,2,2,1,1

if iIf I want that result 2,2,1,1,3,3 or 2,2,3,3,1,1, how can i do it with select query or c# entity framework?

MSSQL Order SELECT List with condition

I want order the select list with condition. For example; I have t1 table and it has 3 columns and 6 rows

Table t1:   
+----+---+---+
| id | x | y |
+----+---+---+
| 1  | a | 1 |
| 2  | b | 3 |
| 3  | c | 2 |
| 4  | d | 2 |
| 5  | e | 1 |
| 6  | f | 3 |
+----+---+---+

Ordering the select list without condition, that select query is easy:
SELECT y FROM t1 ORDER BY y
result: 1,1,2,2,3,3
SELECT y FROM t1 ORDER BY y DESC
result: 3,3,2,2,1,1

if i want that result 2,2,1,1,3,3 or 2,2,3,3,1,1, how can i do it with select query or c# entity framework?

SQL Server Order SELECT List with condition

I want order the select list with condition. For example; I have t1 table and it has 3 columns and 6 rows

Table t1:   
+----+---+---+
| id | x | y |
+----+---+---+
| 1  | a | 1 |
| 2  | b | 3 |
| 3  | c | 2 |
| 4  | d | 2 |
| 5  | e | 1 |
| 6  | f | 3 |
+----+---+---+

Ordering the select list without condition, that select query is easy:
SELECT y FROM t1 ORDER BY y
result: 1,1,2,2,3,3
SELECT y FROM t1 ORDER BY y DESC
result: 3,3,2,2,1,1

If I want that result 2,2,1,1,3,3 or 2,2,3,3,1,1, how can i do it with select query or c# entity framework?

1
source | link

MSSQL Order SELECT List with condition

I want order the select list with condition. For example; I have t1 table and it has 3 columns and 6 rows

Table t1:   
+----+---+---+
| id | x | y |
+----+---+---+
| 1  | a | 1 |
| 2  | b | 3 |
| 3  | c | 2 |
| 4  | d | 2 |
| 5  | e | 1 |
| 6  | f | 3 |
+----+---+---+

Ordering the select list without condition, that select query is easy:
SELECT y FROM t1 ORDER BY y
result: 1,1,2,2,3,3
SELECT y FROM t1 ORDER BY y DESC
result: 3,3,2,2,1,1

if i want that result 2,2,1,1,3,3 or 2,2,3,3,1,1, how can i do it with select query or c# entity framework?