Question

I have a process which prints log in two tables depending of success or failure:

log_mig
log_mig_error

and I want to get the maximum of two fields with the same name:

uid_proc

for adding the consecutive of the current process, this is the query I made so far:

(SELECT MAX(uid_proc) FROM LOG_MIG) UNION ALL (SELECT MAX(uid_proc) FROM log_mig_error)

and this is the output:

MAX(UID_PROC)
00000000000000000008
00000000000000000009

but I want JUST the last row, I tried

SELECT      (SELECT MAX(uid_proc) FROM LOG_MIG) UNION ALL (SELECT MAX(uid_proc) FROM log_mig_error) AS campo 
FROM        log_mig 
INNER JOIN  log_mig_error
WHERE       (log_mig.uid_proc = log_mig_error.uid_proc);

with no success, I may create a view and from them get the maximum, but I don't have permissions to create anything, I must do this at runtime with one step, any help I'll appreciate

Was it helpful?

Solution

If I understand right:

select MAX(uid_proc) from(
(SELECT MAX(uid_proc) as uid_proc FROM LOG_MIG) UNION ALL (SELECT MAX(uid_proc) FROM log_mig_error)
)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top