Hello,
I've two tables AZ01 and AZ02 the structure is the same.
Table AZ01 has 1.681.000 rows and AZ02 has 1.700.000 rows.
I execute the following select: SELECT COUNT(AZ01.COD) AS Conteggio FROM
AZ01 INNER JOIN AZ02 ON AZ01.COD=AZ02.COD
I expect that the maximum number of rows is 1.681.000, but at the end I
get 1.684.000 rows!!! How is it possible?
Thanks for your help!Perhaps SELECT COUNT(DISTINCT col)
"Andrea" <andy@.foo.com> wrote in message
news:e0rg1KkRFHA.1208@.TK2MSFTNGP10.phx.gbl...
> Hello,
> I've two tables AZ01 and AZ02 the structure is the same.
> Table AZ01 has 1.681.000 rows and AZ02 has 1.700.000 rows.
> I execute the following select: SELECT COUNT(AZ01.COD) AS Conteggio FROM
> AZ01 INNER JOIN AZ02 ON AZ01.COD=AZ02.COD
> I expect that the maximum number of rows is 1.681.000, but at the end I
> get 1.684.000 rows!!! How is it possible?
> Thanks for your help!|||If the Key you reference is not unique in the Table AZ02 you will get those
"doubles". It will count the number of rows in the results which match which
each other.
Have a look at this example:
Use Northwind
GO
Select count(Orders.OrderID) From Orders
--> 830
Select count(Orders.OrderID) From Orders inner join [Order Details] OD O
N
OD.OrderID = Orders.OrderId
--> 2155
HTH, Jens Suessmeyer.
http://www.sqlserver2005.de
--
"Andrea" <andy@.foo.com> schrieb im Newsbeitrag
news:e0rg1KkRFHA.1208@.TK2MSFTNGP10.phx.gbl...
> Hello,
> I've two tables AZ01 and AZ02 the structure is the same.
> Table AZ01 has 1.681.000 rows and AZ02 has 1.700.000 rows.
> I execute the following select: SELECT COUNT(AZ01.COD) AS Conteggio FROM
> AZ01 INNER JOIN AZ02 ON AZ01.COD=AZ02.COD
> I expect that the maximum number of rows is 1.681.000, but at the end I
> get 1.684.000 rows!!! How is it possible?
> Thanks for your help!
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment