I have a table with X number of records, but I'm interested that only the first record can be given an extra data, this can be by identifier field , that is, the smallest identifier, this only in order to identify which was the first record to be obtained, at the same time obtain the rest of the data. I guess it would be with CASE
but I'm not sure.
Thank you.
Example of output:
------------------------------
| ID |Nombre | Expr1 |
------------------------------
| 4 |Omar | 1 |
| 9 |Juan | 0 |
| 13 |Maria | 0 |
| 14 |Lupita | 0 |
-Where Expr1
would be the extra data generated by the SQL query.
I would assume it would be something like that, but the syntax is wrong:
SELECT id, nombre, CASE id WHEN MIN(id) THEN '1' ELSE '0' END 'Expr1' FROM tbl_contenido