Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
veeramaga
Starting Member
5 Posts |
Posted - 2006-10-22 : 00:46:13
|
select distinct p.property_id,count(r.property_id)as total_ region,count(t.property_id) as total_tenant from Property pinner joinregion ron p.property_id =r.property_id inner jointenant ton r.property_id = t.property_idand p.property_id= 12group by p.property_idThe above query is to get me the count of region and tenants for each property in the above query I added 5 rows of property_id as 12,when I execute it separately that is, property table and region table I get 5 as the count which is correct, the same way with property table and tenant table the same 5 as count, but if I run like above, joining 3 tables I get the output of count as 25, why is it?can anyone help me out in finding out the reason? |
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2006-10-22 : 09:08:47
|
trycount(distinct r.region_id)as total_ region,count(distinct t.tenant_id) as total_tenantif you have those columns.Get rid of the group by and do a select * to see why you are getting the results.==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
|
|