How To Subtract 2 Count Values Using SQL Statements

//How To Subtract 2 Count Values Using SQL Statements

How To Subtract 2 Count Values Using SQL Statements

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)

Similar Posts:

By |2011-03-08T07:08:07+00:00March 22nd, 2011|Tutorials & Tips|0 Comments

About the Author:

Alvin Poh lives in Singapore, and is interested in marketing, techy stuff, and likes to just figure out how the two can work with each other. He can also be found on Google+.

Leave A Comment


*