Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / General 1 / June 2006

Tip: Looking for answers? Try searching our database.

Help with SQL statement, please

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Thelma Lubkin - 03 Jun 2006 06:43 GMT
I've inherited a SQL statement that looks approximately like this:

SELECT Sum(tblA.A9A) As [1990],
      Sum(tblA.A9A)/Sum(tblA.I9N) As [1990P],
      Sum(tblA.A0A) As [2000],
      Sum(tblA.A0A)/Sum(tblA.I9N) As [2000P]
FROM [geoB]
INNER JOIN tblA
ON [geoB].STFID = tblA.STFID;

1990,2000 refer to years and the number of years that appears in a
SQL varies. I'm uncomfortable with that Sum(tblA.I9N) which will be
repeated for each year in the SQL. Will the SQL automatically be
optimized so that sum is done only once? If not, how do I compute and
name it for use as an intermediate, but not make it one of the items selected?
           
              thanks, --thelma
Bob Quintal - 03 Jun 2006 12:51 GMT
> I've inherited a SQL statement that looks approximately like
> this:
[quoted text clipped - 15 lines]
>            
>                thanks, --thelma

You've also inherited a denormalized table which is a bigger
concern. I don't think thay you'll get much improvement as the
Jet engine appears to calculate all columns in a single pass
through the records.

Signature

Bob Quintal

PA is y I've altered my email address.

Thelma Lubkin - 03 Jun 2006 14:30 GMT
:> I've inherited a SQL statement that looks approximately like
:> this:
[quoted text clipped - 10 lines]
:> which will be repeated for each year in the SQL.
:>               <snip>

: You've also inherited a denormalized table which is a bigger
: concern. I don't think thay you'll get much improvement as the
: Jet engine appears to calculate all columns in a single pass
: through the records.

       Thanks. The question was partly for my education, because I am
       discussing a redesign of the tables with the person maintaining the
       database. I'm not sure how far the redesign can go though, because
       some of the tables used are from an outside source
                                  --thelma

: PA is y I've altered my email address.
Bob Quintal - 03 Jun 2006 16:28 GMT
>:> I've inherited a SQL statement that looks approximately like
>:> this:
[quoted text clipped - 24 lines]
>
>: PA is y I've altered my email address.

I deal with a lot of data that I receive as Text files (some
.sdf, some delimited). I'll usually write a routine that imports
the data to a temp table, then runs queries to either update or
replace the data in properly normalized tables, as applicable.
If the amount of data is not large, one could simply use select
queries against the table to normalize the data for ease in
processing.

Signature

Bob Quintal

PA is y I've altered my email address.

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.