Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8737397
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T10:30:44+00:00 2026-06-13T10:30:44+00:00

INTRODUCTION TO DATABASE TABLE BEING USED – I am working on a Stock Market

  • 0

INTRODUCTION TO DATABASE TABLE BEING USED –

I am working on a “Stock Market Prices” based Database Table. My table has got the data for the following FIELDS –

ID
SYMBOL
OPEN
HIGH
LOW
CLOSE
VOLUME
VOLUME CHANGE
VOLUME CHANGE %
OPEN_INT
SECTOR
TIMESTAMP

New data gets added to the table daily “Monday to Friday”, based on the stock market price changes for that day. The current requirement is based on the VOLUME field, which shows the volume traded for a particular stock on daily basis.

REQUIREMENT –
To get the Average and Total Volume for last 10,15 and 30 Days respectively.

METHOD USED CURRENTLY –
I created these 9 SEPARATE QUERIES in order to get my desired results –
First I have created these 3 queries to take out the most recent last 10,15 and 30 dates from the current table:

qryLast10DaysStored
qryLast15DaysStored
qryLast30DaysStored

Then I have created these 3 queries for getting the respective AVERAGES:

qrySymbolAvgVolume10Days
qrySymbolAvgVolume15Days
qrySymbolAvgVolume30Days

And then I have created these 3 queries for getting the respective TOTALS:

qrySymbolTotalVolume10Days
qrySymbolTotalVolume15Days
qrySymbolTotalVolume30Days

PROBLEM BEING FACED WITH CURRENT METHOD –
Now, my problem is that I have ended up having these so many different queries, whereas I wanted to get the output into One Single Query, as shown in the Snapshot of the Excel Sheet:

http://i49.tinypic.com/256tgcp.png

SOLUTION NEEDED –
Is there some way by which I can get these required fields into ONE SINGLE QUERY, so that I do not have to look into multiple places for the required fields? Can someone please tell me how to get all these separate queries into one –
A) Either by taking out or moving the results from these separate individual queries to one.
B) Or by making a new query which calculates all these fields within itself, so that these separate individual queries are no longer needed. This would be a better solution I think.

One Clarification about Dates –
Some friend might think why I used the method of using Top 10,15 and 30 for getting the last 10,15 and 30 Date Values. Why not I just used the PC Date for getting these values? Or used something like –

("VOLUME","tbl-B", "TimeStamp BETWEEN Date() - 10 AND Date()")

The answer is that I require my query to “Read” the date from the “TIMESTAMP” Field, and then perform its calculations accordingly for LAST / MOST RECENT “10 days, 15 days, 30 days” FOR WHICH THE DATA IS AVAILABLE IN THE TABLE, WITHOUT BOTHERING WHAT THE CURRENT DATE IS. It should not depend upon the current date in any way.

If there is any better method or more efficient way to create these queries, then please enlighten.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T10:30:45+00:00Added an answer on June 13, 2026 at 10:30 am

    Access doesn’t support most advanced SQL syntax and clauses, so this is a bit of a hack, but it works, and is fast on your small sample. You’re basically running 3 queries but the Union clauses allow you to combine into one:

    select
       Symbol,
       sum([10DayTotalVol]) as 10DayTotalV,
       sum([10DayAvgVol]) as 10DayAvgV,
       sum([15DayTotalVol]) as 15DayTotalV,
       sum([15DayAvgVol]) as 15DayAvgV,
       sum([30DayTotalVol]) as 30DayTotalV,
       sum([30DayAvgVol]) as 30DayAvgV
    
    from (
    
          select
            Symbol, 
            sum(volume) as 10DayTotalVol, avg(volume) as 10DayAvgVol,
            0 as 15DayTotalVol, 0 as 15DayAvgVol,
            0 as 30DayTotalVol, 0 as 30DayAvgVol
          from
             [tbl-b]
          where
             timestamp >= (select min(ts) from (select distinct top 10 timestamp as ts from [tbl-b] order by timestamp desc ))
          group by
             Symbol   
    
          UNION
    
          select
            Symbol, 
            0, 0,
            sum(volume), avg(volume),
            0, 0
          from
             [tbl-b]
          where
             timestamp >= (select min(ts) from (select distinct top 15 timestamp as ts from [tbl-b] order by timestamp desc ))
          group by
             Symbol    
    
          UNION
    
          select
            Symbol, 
            0, 0,
            0, 0,
            sum(volume), avg(volume)
          from
             [tbl-b]
          where
             timestamp >= (select min(ts) from (select distinct top 30 timestamp as ts from [tbl-b] order by timestamp desc ))
          group by
             Symbol 
          ) s
    
    group by 
       Symbol
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We are working on custom ETL tool. We extract data from database in files,
I have File-Stream enabled database. I have created table with column that has the
Introduction I've got a problem with my extension for Chrome. It supposed to show
Introduction: I'm trying to get additional fields to log with log4j, and its working
Introduction In a current project I'm working on we're using the ChartBoost SDK for
Introduction The Model-View-Controller approach has been in my head since before the holidays and
The following link descrip about Non-Relational field types in database: http://wiki.developerforce.com/page/An_Introduction_to_Force_Database one of field
First a little introduction. We have an SQL Server Express 2008 database, which schema
Introduction Google chrome has a feature that allows you to create shortcuts to web
OK, so I got past the tutorial introduction to git and I know how

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.