I have a table, something like
STUDENTNAME ISMANUALLYADDED ISEDITED
----------- --------------- --------
APPLE 0 0
ANT 0 1
BELL 0 0
DOLL 1 0
Here, I am trying to sort the data by studentname first, by ismanuallyadded, and then by isedited. I am expecting the result like:
StudentName
-----------
APPLE
BELL
DOLL
ANT
For this, I am trying like,
select studentname from table1
order by studentname, ismanuallyadded, isedited
but, this query gives the result like,
Student
-------
APPLE
ANT
BELL
DOLL
Is it possible to order by studentname first and then order by ismanuallyadded?
I am trying to display all the studentnames (neither manually added nor isedited) alphabetically, then only ismanuallyadded students should come, and then isedited.
The second criteria in the order by is only used when different rows have the same value in the previous criteria.
Your rows all have different studentname values, so the second and third criteria are never used.
Try this:
select studentname from table1
order by isedited, ismanuallyadded, studentname
Try this
select studentname from table1
order by studentname ASC, ismanuallyadded ASC, isedited ASC
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With