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 / Queries / December 2005

Tip: Looking for answers? Try searching our database.

date query / multiple fields

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
MARTIN95 - 01 Dec 2005 03:26 GMT
i have one table with lastname, first name, (10) date fields with a service
and price field connected to each date.

i'm trying to create a weekly sales report so i need a query that will look
at each date field in the table and return the results for the user specified
starting and ending dates and hopefully if possible eliminate the fields that
have no data.

so if possible show the results as follows:

ie:     smith, anna             service01         $10.00
        jones, george          service 03        $25.00

        ending weekly total                        $35.00

can anyone help
Tom Ellison - 01 Dec 2005 03:53 GMT
Dear Martin:

The fundamental difficulty here is that you have repeated the date and price
columns 10 times.  A properly constructed database would have only one date
and price value per row.

You can temporarily overcome this by creating the appearance that your data
were stored properly.  This can be done by a normalizing UNION query:

SELECT LastName, FirstName, "01" as Service, Date01, Price01
 FROM YourTable
 WHERE Date01 IS NOT NULL
UNION ALL
SELECT LastName, FirstName, "02" as Service, Date02, Price02
 FROM YourTable
 WHERE Date02 IS NOT NULL

repeat this till you have all 10 date/price combinations.  You must correct
the column and table names I have assigned, as I don't know exactly how you
have done this.

You can then easily query the above to show only those rows belonging to the
user defined period.

A grand total can also be produced using a separate query, or as a total on
a report.

Tom Ellison

>i have one table with lastname, first name, (10) date fields with a service
> and price field connected to each date.
[quoted text clipped - 15 lines]
>
> can anyone help
 
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.