We use order by to get sorted result in SQL.
But when we need specific order, then we can use this solution.
select name,job_card_status,
CASE job_card_status
WHEN 'Not Created' THEN 1
WHEN 'Created' THEN 2
WHEN 'Submitted' THEN 3
ELSE 5
END as id
from `tabSample Entry Register` order by id
Sorted record based on two column:Here id is ascending and name is in descending, so we will get latest Sample Entry with job not created status
select name,job_card_status,
CASE job_card_status
WHEN 'Not Created' THEN 1
WHEN 'Created' THEN 2
WHEN 'Submitted' THEN 3
ELSE 5
END as id
from `tabSample Entry Register` order by id, name desc
No comments:
Post a Comment