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.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 4 inner joins giving me duplicate values

Author  Topic 

saba9
Starting Member

4 Posts

Posted - 2010-02-12 : 14:50:27
Hi,
Can someone help me out
select distinct cust.no, cust.branch, cust.name, cust.surname, term.benefit, term.code,tehi.trcode, tehi.trancode, dmhi.trancode, dmd.benefit
from
cust as cust inner join term as term on cust.rowno = term.rowno_custterm_cust
inner join tehi as tehi on term.rowno =tehi.rowno_termtehi_term
inner join dmd as dmd on cust.rowno =dmd.rowno_custdmd_cust
inner join dmhi as dmhi on dmd.rowno =dmhi.rowno_dmddmhi_dmd

I have tried with group by and having count but that gives me an error (it takes forever and then sql says doesnt have enough memory to sort)

sodeep
Master Smack Fu Yak Hacker

7174 Posts

Posted - 2010-02-12 : 15:01:28
See ROW_Number() Function. Do you have indexes in tables?
Go to Top of Page

saba9
Starting Member

4 Posts

Posted - 2010-02-12 : 15:19:54
No I don't have indexes
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-02-13 : 10:04:41
please provide some sample data and then explain what you want

http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -