I have the following table:
name | age |
---|---|
pedro | 11 |
duda | 12 |
joao | 7 |
pedro | 9 |
guga | 10 |
pedro | 13 |
zelda | 10 |
What I want is to select all entries here in which age >= 10
, but at the same time keep all results which name = pedro
in the last position, like this:
name | age |
---|---|
duda | 12 |
guga | 10 |
zelda | 10 |
pedro | 11 |
pedro | 13 |
So there are two questions:
is it possible to do it with a select statement?
Yes you can use where
and order by
with case
like:
select *
from table
where age >= 10
order by case name when 'pedro' then 2 else 1 end