hola,
tengo esta consulta de PL/SQL y necesito pulir el campo s.LAST_NUMBER (el resto de laconsulta ya es válida y no puedo cambiarla)
El CASE WHEN del campo s.LAST_NUMBER necesito que me devuelva el MAX(c.COLUMN_NAME) FROM c.TABLE_NAME, pero no sé como...
SELECT c.TABLE_NAME, c.COLUMN_NAME,
CASE WHEN s.LAST_NUMBER is null THEN -1 ELSE s.LAST_NUMBER END AS LAST_NUMBER,
s.SEQUENCE_NAME, t.TRIGGER_NAME, t.TRIGGER_BODY
FROM USER_TAB_COLUMNS c LEFT JOIN USER_SEQUENCES s ON c.COLUMN_NAME = s.SEQUENCE_NAME LEFT JOIN USER_TRIGGERS t on c.TABLE_NAME = t.TABLE_NAME
WHERE c.DATA_TYPE = 'NUMBER' and C.DATA_PRECISION is null
ORDER BY c.TABLE_NAME;
Pueden ayudarme?
Gracias!