I find it’s hard to write the title for this topic, so here’s the problem.
I have a table like:
id | name | status | reg_date
---+-------+---------+-----------
1 | Jerry | online | 2016-09-12
2 | Mary | offline | 2016-09-02
3 | Rick | online | 2016-09-06
4 | Sarah | offline | 2016-09-13
5 | Donny | online | 2016-09-01
6 | Naomi | online | 2016-08-31
7 | Peter | online | 2016-08-21
What I want to get is, to have 5 person order by reg_date for both status, but, I only want one person with ‘offline’ status. So, from the table I will have result like below:
id | name | status | reg_date
---+-------+---------+-----------
4 | Sarah | offline | 2016-09-13
1 | Jerry | online | 2016-09-12
3 | Rick | online | 2016-09-06
5 | Donny | online | 2016-09-01
6 | Naomi | online | 2016-08-31