If you’re developing an application that makes use of SQL statements, you may come across a time when you’ll require to count() values from a table. You may also come across a time when you’ll need to subtract a count() value from another. The good news is that you don’t have to retrieve both count() values separately and then subtract them in your application’s code – you can actually just use a single SQL to obtain this value, and this is the SQL format that you should use:
SELECT (SELECT COUNT(*) FROM table1) - (SELECT COUNT(*) FROM table2)
it is incorrect sql example.