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)
 Problem to solve....

Author  Topic 

duhaas
Constraint Violating Yak Guru

310 Posts

Posted - 2007-07-17 : 16:21:17
You guys were great awhile back to help me with the following

SELECT s.babr,s.sicid,isnull(s.SicDescription,'Non-Inst and/or not coded') as sicdescription,
SUM(s.AccountMV) AS mv, SUM(s.AccountMV) / q.ps AS Percentile
FROM SnapsRaw s INNER JOIN
(SELECT babr, SUM(accountmv) ps
FROM snapsraw
WHERE monthend = '06/01/2007'
GROUP BY babr) q ON q.babr = s.babr
WHERE s.MonthEnd = '06/01/2007' and branchstate <> 'Institutional Agency'
GROUP BY s.Babr, s.SicDescription, q.ps, q.babr,s.sicid
having SUM(s.AccountMV) / q.ps > 0.0
order by sicdescription


For some reason why I run it with my new months data, it just runs and runs and runs, if I run it with 05/01/2007 data it runs in a couple seconds. I am having a hard time identifying which fields I should pay attention to so that I can find the data that appears to be causing some type of loop

duhaas
Constraint Violating Yak Guru

310 Posts

Posted - 2007-07-17 : 17:01:43
If i delcare the @date variable before running the query above and leaving the where statements with the @date it runs, but when i put in '06/01/2007' it just keeps chugging along, just weird how '05/01/2007' runs fine that way????
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-07-17 : 21:58:45
please provide table DDL and sample data for your scenario


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-07-18 : 05:22:38
Is really the first of June a month's end?


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

duhaas
Constraint Violating Yak Guru

310 Posts

Posted - 2007-07-18 : 07:37:48
ha ha ha, just my goofy way i guess i indicating june data
Go to Top of Page

duhaas
Constraint Violating Yak Guru

310 Posts

Posted - 2007-07-18 : 10:41:13
we did a reindex on the table and that seem to solve the problem. not sure i can answer myself why that solved the problem, but it did. any ideas as to why that would of solved the problem????
Go to Top of Page
   

- Advertisement -