troubleshooting Question

Sql Query alternate

Avatar of JonMny
JonMny asked on
Microsoft SQL Server
5 Comments2 Solutions320 ViewsLast Modified:
I have this query (simplified). I have narrowed down the issue to the Amount column query. I know if I can move that column query to the bottom and join it will be faster. I have written the query doing so and I get the results that I need except it gives me extra rows. Can anyone suggest how this might be done.

                        Select top 1
                              AccountHistory i
                              i.TheDate >= '1/1/2011' and
                              aID Between '0' and '9' and
                              o.aID = i.aID and
                              o.aID = i.aID and
                              o.FG = i.FG and
                              o.TheDate >= i.TheDate
                        Order by
                              i.TheDate desc
                  ) as Amount,
Michael Carrillo
Information Systems Manager
Join our community to see this answer!
Unlock 2 Answers and 5 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 5 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros