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 |
|
thor
Starting Member
1 Post |
Posted - 2005-10-17 : 09:12:37
|
| In the guery below I have a where "orh_selger_id = 'GEIR'"The problem is that the query neglect this "orh_selger_id = 'GEIR'" in the clause. All else seems to be right. Why do query neglect this in the clause ??select ut_id, bl_blad from bl_blad join ut_utgave on ut_bl_id = bl_id Full join orh_ordrehode on orh_bl_id = bl_id full join orl_ordrelinje on orl_orh_id = orh_nummer full join SuperOffice.crm5.contact A on A.contact_id = orh_kunde_id full join SuperOffice.crm5.contact B on B.contact_id = orh_annonsor_id where ut_id > '0' and orh_bl_id = '21' and (ut_mnd >= '01' and ut_aar >= '05') and (ut_mnd <= '07' and ut_aar <= '05') and orh_selger_id = 'GEIR' group by ut_id, bl_blad order by bl_blad |
|
|
TG
Master Smack Fu Yak Hacker
6065 Posts |
Posted - 2005-10-17 : 10:07:55
|
| Hi thor, There is no where clause in your statement. You are using FULL OUTER JOINs and it is the join criteria that has the condition so the query is behaving exactly as it should. If you want some changes made we can help, but you'll need to post some detailed requirements. see this link for help with that:http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspxEDIT:woops, I just noticed there is a WHERE in your statement. The lack of formatting through me off. I'll have a closer look in a sec...Be One with the OptimizerTG |
 |
|
|
chiragkhabaria
Master Smack Fu Yak Hacker
1907 Posts |
Posted - 2005-10-17 : 10:10:47
|
| hey i guess u missed out there is the where clause in the statement.. select ut_id, bl_blad from bl_blad join ut_utgave on ut_bl_id = bl_id Full join orh_ordrehode on orh_bl_id = bl_id full join orl_ordrelinje on orl_orh_id = orh_nummer full join SuperOffice.crm5.contact A on A.contact_id = orh_kunde_id full join SuperOffice.crm5.contact B on B.contact_id = orh_annonsor_id where ut_id > '0' and orh_bl_id = '21' and (ut_mnd >= '01' and ut_aar >= '05') and (ut_mnd <= '07' and ut_aar <= '05') and orh_selger_id = 'GEIR' group by ut_id, bl_blad order by bl_bladComplicated things can be done by simple thinking |
 |
|
|
TG
Master Smack Fu Yak Hacker
6065 Posts |
Posted - 2005-10-17 : 10:37:26
|
>>hey i guess u missed out there is the where clause in the statement.. yeah, I caught that...I noticed you didn't pipe in with any answers though Since your query groups by ut_id and bl_blad with no other aggregates, how do you know the where condition is being ignored?To test, remove the group by and add the orh_selger_id column.<EDIT>if you still can't figure it out, follow the instruction on the link above post your followup question.<ENDEDIT>On a different note:It's really hard to read this statement because it is filled with potential ambiguity. You don't consistently use qualified column names and table aliases. You should either use table aliases through out your statement or the full table names throughout your statement. Same with your use of parenthesis. Some formatting would make it a lot easier to read as well. Be One with the OptimizerTG |
 |
|
|
|
|
|
|
|