Need to check if one table contains the max id from another table...
I have two tables, "emplist" and "deptinfo".
In the first table "emplist" is a list of employees as follows:
Then there is a smaller list "deptinfo" where there is one entry per department as follows:
The "lastid" is the id of the last employee added to emplist. So normally max(empid) in table emplist should always match "lastid" in table depinfo for deptinfo.deptcode == emplist.dept.
To verify this, I run these two SQL statements which will generate two lists then I visually compare the two lists to make sure the "lastid" of the second table matches the max(empid) of the first table.
select dept, max(empid) from emplist group by dept order by dept;
select deptcode,lastid from deptinfo ORDER BY team;
My question is… How can I write a SQL statement that will give the intersection of the two tables when emplist.max(empid) .NE. deptinfo.lastid?
8/22/2022 - Mon
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat