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
 General SQL Server Forums
 New to SQL Server Programming
 Alternative for MINUS query

Author  Topic 

selvaspk
Starting Member

3 Posts

Posted - 2008-12-09 : 10:07:13
Hi,
I am using Teradata and when i use the MINUS queries,
i get a slow performance. But my scenario is i need to compare a lot of fields with other table and writing with MINUS is easy and iis there any alternative i could use instead of that?
I am new and struck with this.

Thanks in advance.
Selva

sodeep
Master Smack Fu Yak Hacker

7174 Posts

Posted - 2008-12-09 : 10:22:01
Can you explain clearly with queries as well?
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-12-09 : 10:24:10
try left join
Go to Top of Page

selvaspk
Starting Member

3 Posts

Posted - 2008-12-09 : 10:27:19
quote:
Originally posted by sodeep

Can you explain clearly with queries as well?


Scenario 1:
sel A.C1, A.C2, A.C3, A.C4
from table A
group by 1,2,3,4

Minus

sel B.C1, B.C2, B.C3, B.C4
from table B
group by 1,2,3,4


Scenario 2:
in this the C3 and C4 are amount columns.

sel A.C1, A.C2, sum(A.C3), sum(A.C4)
from table A
group by 1,2,3,4

Minus

sel B.C1, B.C2, sum(B.C3), Sum(B.C4)
from table B
group by 1,2,3,4
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-12-09 : 10:27:32
or even not exists will do
Go to Top of Page

selvaspk
Starting Member

3 Posts

Posted - 2008-12-09 : 10:30:45
quote:
Originally posted by visakh16

or even not exists will do



you mean for the amount col also we can use not exists?
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-12-09 : 10:45:01
yup...why not?
Go to Top of Page
   

- Advertisement -