Welcome to SPN

Register and Join the most happening forum of Sikh community & intellectuals from around the world.

Sign Up Now!
  1.   Become a Supporter    ::   Make a Contribution   
    Target (Recurring Monthly): $200 :: Achieved: $98

Access2000: Query

Discussion in 'Information Technology' started by Arvi Laanemets, Nov 19, 2005.

  1. Arvi Laanemets

    Arvi Laanemets
    Expand Collapse


    I have a table where routes for cars are registered
    Routes: RouteID, EndTime, CarID, ..., EndKm
    (EndKm is total mileage for particular car after route, and is entered into
    table by user)

    I have a query (p.e. Q1, which returns total mileage for every car in Routes
    table after latest
    route for every month:

    SELECT b.MonthStr, a.CarID, a.EndKm As KmX
    FROM Routes AS a, Q2 AS b
    WHERE a.EndTime= b.TimeX AND a.CarID=b.CarID;

    , where Q2:
    SELECT Format$([Routes].[EndTime],'yyyy\.mm') AS MonthStr, Routes.CarID,
    MAX(Routes.EndTime) AS TimeX
    FROM Routes
    GROUP BY Format$([Routes].[EndTime],'yyyy\.mm'), Routes.CarID;

    This all works. But I need now another column in query Q1, where starting
    mileage for those cars and months is calculated. The rules for such
    calculation are:
    - the starting mileage (Km0) will be equal to latest existing mileage
    entry in Routes table for this car from all previous months.
    - when there were no entries for this car before the month, calculation
    is made for, the Km0 equals to according mileage value from special starting
    parameters table (StartValues)

    StartValues: EntryID, CarID, Date, Km, ...
    (any car can have several entries here - it depends on date, which one is
    taken in account)

    I.e. the query Q1 must be something like
    SELECT b.MonthStr, a.CarID, <Expression> As Km0, a.EndKm As KmX
    FROM Routes AS a, Q2 AS b, ...
    WHERE a.EndTime= b.TimeX AND a.CarID=b.CarID ...;

    Has anyone some idea for best way to achieve this?
    Thanks in advance!
    Arvi Laanemets
  2. Loading...

    Similar Threads Forum Date
    Query about Jhatka Meat by Shooting in Head Sikh Sikhi Sikhism Aug 26, 2011
    Who is a sikh? A non sikh friend's query!! Sikh Sikhi Sikhism Apr 30, 2010
    General Query Hard Talk Sep 4, 2008
    Power of pauri's in Japji Sahib query Sikh Sikhi Sikhism Aug 17, 2006
    Sikhism a query Book Reviews & Editorials Aug 2, 2005

Since you're here... we have a small favor to ask...

More people are visiting & reading SPN than ever but far fewer are paying to sustain it. Advertising revenues across the online media have fallen fast. So you can see why we need to ask for your help. Donating to SPN's is vote for free speech, for diversity of opinions, for the right of the people to stand up to religious bigotry. Without any affiliation to any organization, this constant struggle takes a lot of hard work to sustain as we entirely depend on the contributions of our esteemed writers/readers. We do it because we believe our perspective matters – because it might well be your perspective, too... Fund our efforts and together we can keep the world informed about the real Sikh Sikhi Sikhism. If everyone who writes or reads our content, who likes it, helps us to pay for it, our future would be much more secure. Every Contribution Matters, Contribute Generously!

    Become a Supporter      ::     Make a Contribution     

Share This Page