I can perform the following SQL Server selection of individual (or non-duplicate names) from a column in a single table as follows:
SELECT COUNT(DISTINCT [Name]) FROM [MyTable]
But what if I have more than one table (all these tables contain a name field called [Name]), and I need to know the number of unique names in two or more tables.
If I ran something like this:
SELECT COUNT(DISTINCT [Name]) FROM [MyTable1], [MyTable2], [MyTable3]
I get the error message: "Ambiguous column name" Name ".
PS. All three tables [MyTable1], [MyTable2], [MyTable3] are the product of the previous selection.
ahmd0 source share