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 |
thanksfor help
Posting Yak Master
106 Posts |
Posted - 2008-02-22 : 18:39:22
|
Hi,I have table which have to be self joined to do some calculation. here is sample of the tableaid aname monthid region amount1 sales jan asia 10002 sales1 jan asia 1001 sales jan europe 20002 sales1 jan europe 2001 sales jan us 30002 sales1 jan us 300percentage = (sales/sales1) * 100select a.amount, b.amount from tbl1 ainner join tbl1 b on a.monthid = b.monthid and a.region = b.region and a.acid <> b.acidwhere a.acid in (1,2) and b.acid in (1,2) ---- because there are other account type in the tableand a.acid < b.acidThis query works perfect, but I want to know is there any other best alternative as the table size is growing fast.thanks in advance. |
|
bbasir
Yak Posting Veteran
76 Posts |
Posted - 2008-02-22 : 18:47:52
|
have you created indexes on the where condition fields? and join fields.. that woudl help. |
 |
|
|
|
|