I'm trying to get a sub group of records to display first before the rest of the group.
For example, I make a selection of real estate properties and the result is 22 records. The records are ordered by 'price'. Two of these records, which belong to a partcular agent, I want to have show up above the others. There is a column in the real estate property table that holds the agent's id so I know what two records belong to this agent.
It's been suggested that I try the following but the CASE segment is causing a syntax error. Is it possible to make this work or is there a better way to approach this?
SELECT idx_res.*, CASE WHEN idx_res.agent_id = 1897 THEN 0 ELSE 1 END AS orderfield
FROM idx_res
WHERE idx_res.area = 'DSE'
ORDER BY orderfield, price
For example, I make a selection of real estate properties and the result is 22 records. The records are ordered by 'price'. Two of these records, which belong to a partcular agent, I want to have show up above the others. There is a column in the real estate property table that holds the agent's id so I know what two records belong to this agent.
It's been suggested that I try the following but the CASE segment is causing a syntax error. Is it possible to make this work or is there a better way to approach this?
SELECT idx_res.*, CASE WHEN idx_res.agent_id = 1897 THEN 0 ELSE 1 END AS orderfield
FROM idx_res
WHERE idx_res.area = 'DSE'
ORDER BY orderfield, price