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 |
divyaat
Starting Member
1 Post |
Posted - 2014-03-05 : 12:07:52
|
Hi ,Could you please help me in finding the solution for the below query?It displays repeated records.Kindly help me on this since am a beginner.select distinct ku.username,rro.role_name,rp.resource_type_code,kr.region_name,kc.currency_name,fcr.cost_rule_id RULE,fcr.rate current_rate,pp.project_name,kou.org_unit_name ORG_UNITfrom knta_users ku,RSC_RESOURCES rr,RSC_RESOURCE_ROLES rrr,RSC_ROLES rro,RSC_POSITIONS rp,KNTA_REGIONS kr,KCST_CURRENCIES kc,FM_COST_RATES fcr,FM_COST_RULES fcru,PM_PROJECTS pp,KRSC_ORG_UNITS kouwhere ku.user_id = rr.user_id and rr.resource_id = rrr.resource_idand rrr.role_id = rro.role_idand rro.role_id = rp.role_idand ku.region_id = kr.region_idand kr.currency_id = kc.currency_idand kc.currency_code = fcr.currency_codeand fcr.cost_rule_id = fcru.cost_rule_idand kr.region_id = pp.region_idand ku.manager_user_id = kou.manager_idKind Regards |
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2014-03-05 : 12:11:46
|
It displays repeated records because you have a one to many relationship between two or more of the tables. You'll need to determine which rows you'll want to keep. ROW_NUMBER() function can be helpful for this.And you need to start using proper JOIN syntax. Join conditions should not be in the WHERE clause. You should have only one table in the FROM. Use joins for the other tables.Tara KizerSQL Server MVP since 2007http://weblogs.sqlteam.com/tarad/ |
|
|
maunishq
Yak Posting Veteran
71 Posts |
Posted - 2014-03-05 : 13:51:44
|
Which database are you using?=======================Not an Expert, Just a learner.!_(M)_! |
|
|
|
|
|
|
|