hi
i have a database with two tables
Table 1 contains the following fields
area , date, breakdowns, cost
the date field is formatted as short date
the date is assigned when the record is entered by the user
table two has the following fields
area, monthly cost, month, year
the cost is input manually monthly as is the month and year.
now i join the tables together on the area field
i need to total my cost for a 12 month period by month and year based on
a combobox selection ie. 2004
giving
jan feb mar apr etc...
home 20 60 90 10
can anyone please tell how to do this
thanks in advance
kevin 2 1086
Air coded:
SELECT T2.Area,
SUM(IIf(T2.Month = 1, T1.Cost, 0) AS Jan,
SUM(IIf(T2.Month = 2, T1.Cost, 0) AS Feb,
SUM(IIf(T2.Month = 3, T1.Cost, 0) AS Mar,
SUM(IIf(T2.Month = 4, T1.Cost, 0) AS Apr,
SUM(IIf(T2.Month = 5, T1.Cost, 0) AS May,
SUM(IIf(T2.Month = 6, T1.Cost, 0) AS Jun,
SUM(IIf(T2.Month = 7, T1.Cost, 0) AS Jul,
SUM(IIf(T2.Month = 8, T1.Cost, 0) AS Aug,
SUM(IIf(T2.Month = 9, T1.Cost, 0) AS Sep,
SUM(IIf(T2.Month = 10, T1.Cost, 0) AS Oct,
SUM(IIf(T2.Month = 11, T1.Cost, 0) AS Nov,
SUM(IIf(T2.Month = 12, T1.Cost, 0) AS Dec
FROM Table1 AS T1
INNER JOIN Table2 AS T2 ON (T2.Area = T1.Area AND T2.Month =
MONTH(T1.Date) AND T2.Year = Year(T1.Date))
WHERE T2.Year = YourComboboxValue
GROUP BY T2.Area
ORDER BY T2.Area
Yannick
"kevin carter" <ke***@carter5711.freeserve.co.uk> wrote in message
news:2f**************************@posting.google.c om... hi i have a database with two tables Table 1 contains the following fields
area , date, breakdowns, cost
the date field is formatted as short date the date is assigned when the record is entered by the user
table two has the following fields area, monthly cost, month, year
the cost is input manually monthly as is the month and year.
now i join the tables together on the area field
i need to total my cost for a 12 month period by month and year based on a combobox selection ie. 2004 giving
jan feb mar apr etc... home 20 60 90 10
can anyone please tell how to do this
thanks in advance
kevin
Correction (forgot a parenthesis)... still air coded!
SELECT T2.Area,
SUM(IIf(T2.Month = 1, T1.Cost, 0)) AS Jan,
SUM(IIf(T2.Month = 2, T1.Cost, 0)) AS Feb,
SUM(IIf(T2.Month = 3, T1.Cost, 0)) AS Mar,
SUM(IIf(T2.Month = 4, T1.Cost, 0)) AS Apr,
SUM(IIf(T2.Month = 5, T1.Cost, 0)) AS May,
SUM(IIf(T2.Month = 6, T1.Cost, 0)) AS Jun,
SUM(IIf(T2.Month = 7, T1.Cost, 0)) AS Jul,
SUM(IIf(T2.Month = 8, T1.Cost, 0)) AS Aug,
SUM(IIf(T2.Month = 9, T1.Cost, 0)) AS Sep,
SUM(IIf(T2.Month = 10, T1.Cost, 0)) AS Oct,
SUM(IIf(T2.Month = 11, T1.Cost, 0)) AS Nov,
SUM(IIf(T2.Month = 12, T1.Cost, 0)) AS Dec
FROM Table1 AS T1
INNER JOIN Table2 AS T2 ON (T2.Area = T1.Area AND T2.Month =
MONTH(T1.Date) AND T2.Year = Year(T1.Date))
WHERE T2.Year = YourComboboxValue
GROUP BY T2.Area
ORDER BY T2.Area
"Yannick Turgeon" <no****@nowhere.com> wrote in message
news:s_********************@news20.bellglobal.com. .. Air coded:
SELECT T2.Area, SUM(IIf(T2.Month = 1, T1.Cost, 0) AS Jan, SUM(IIf(T2.Month = 2, T1.Cost, 0) AS Feb, SUM(IIf(T2.Month = 3, T1.Cost, 0) AS Mar, SUM(IIf(T2.Month = 4, T1.Cost, 0) AS Apr, SUM(IIf(T2.Month = 5, T1.Cost, 0) AS May, SUM(IIf(T2.Month = 6, T1.Cost, 0) AS Jun, SUM(IIf(T2.Month = 7, T1.Cost, 0) AS Jul, SUM(IIf(T2.Month = 8, T1.Cost, 0) AS Aug, SUM(IIf(T2.Month = 9, T1.Cost, 0) AS Sep, SUM(IIf(T2.Month = 10, T1.Cost, 0) AS Oct, SUM(IIf(T2.Month = 11, T1.Cost, 0) AS Nov, SUM(IIf(T2.Month = 12, T1.Cost, 0) AS Dec FROM Table1 AS T1 INNER JOIN Table2 AS T2 ON (T2.Area = T1.Area AND T2.Month = MONTH(T1.Date) AND T2.Year = Year(T1.Date)) WHERE T2.Year = YourComboboxValue GROUP BY T2.Area ORDER BY T2.Area This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Jerome |
last post by:
Hi,
I know this is an old problem and I've already tried to look the
solution up on the web but I didn't find what I need.
So, there's the following situation:
I've got an ASP page with a...
|
by: Lyn |
last post by:
Hi,
I am developing a project in which I am checking for records with
overlapping start/end dates. Record dates must not overlap date of birth,
date of death, be in the future, and must not...
|
by: StBond |
last post by:
Hi everyone,
I am new to Access and Visual Basic so things my be getting across a
bit cloudy. I only started using VB for one week.
I am having a little problem with the database that I am...
|
by: Andy_Khosravi |
last post by:
I have been trying to build a user friendly search engine for a small
database I have created. I'm having some particular problems with one
of my date fields.
Here's the setup:
I'm using...
|
by: Geoff Jones |
last post by:
Hi
I have a table that has a column with Date types.
I am trying to view certain rows in the table using a DataView.
Using the filter, I can view the rows with, for example, the date equal...
|
by: seegoon |
last post by:
Hi to all.
I have a small problem I hope someone can help me with.
I am running a sql query to a csv file. The query searches for the
total of a column between 2 dates.
This is a copy of one of...
|
by: hardik |
last post by:
hi friends,
i am really surprized the way access behaves in date fields i mean
it's all ok when you have us time zone or us servers but if you have
diffrent timezone like uk then access creates...
|
by: Dave |
last post by:
Hello,
I have a possible problem exporting a text field that happens to
contain dates (but is not a date field) when using TransferText in MS
Access 2000.
I am exporting a query to a text...
|
by: creative1 |
last post by:
Hello everyone.
I am experiencing a strange problem that I can't fix on my own. I think I need expert's suggestions for this.
The problem is:
I want to print account statement (or any other...
|
by: Ceebaby via AccessMonster.com |
last post by:
Hi Folks
I wondered if someone could point me in the right direction before I
completely tear my hair out.
I have a user selection form where options can be selected for a report.
Users now...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
| |