473,405 Members | 2,415 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Query to show letters sent by date in a crosstab format

Hi,

I'm back with the same question as I still can't get it to display
my data the way I want it to.

The table lists information about a perpetrator involved with an anti
social behaviour order. The table contains personal information about
the individual as well as (here is where the letter dates comes in:)
e.g.

Surname:
Forename:
DOB:
Address1:
Address2:
Address3:
Address4:
PostCode:
Date Poor Behaviour Letter Sent: 01/04/05
Date First Warning Letter Sent: 10/04/05
Date Second Warning Letter Sent: 20/04/05
Date Consult SS Letter Sent: 28/04/05
etc....
etc....

The structure of the system that surrounds this table is:

tblCase - this has a 1:M relationship with:
tblIncident - this has a 1:M relationship with:
tblIncidentPerpetrator

I would like a total of all letters sent to all perpetrators having
months across the top, the letter type down the left and a count/total
of them within, an example is shown below.

Jan Feb Mar Apr May
etc..
Date Poor Behaviour Letter Sent 30 15 10 43 12
Date First Warning Letter Sent 12 7 3 12 2
Date Second Warning Letter Sent 2 1 0 1 0
Date Consult SS Letter Sent 1 0 0 0 0

I have tried using a crosstab query (actually several of them) but
cannot get it to calculate and display the data the way I want it to.

I have even created a table containg the 12 months and tried to link it
to a query that shows my results as months instead of dates using:
format([<<Field>>],"mmm")

I have ran out of ideas and not even sure if what I'm trying to do is
possible using a query or crosstab. I may have to create an individual
query and report for each letter and put them all as subreports into
one report so that they appear on 1 page as 1 report.

Any help would be appreciated.

Regards.

CJB

Nov 13 '05 #1
2 2229
Carl:

One approach is to create a crosstab query for each of your four dates and
then union the four queries together to get the final query results.

The crosstab for Poor Behavior might look like the following:

TRANSFORM Count(Test4.PoorBehav) AS CountOfPoorBehav
SELECT "PoorBehavior" AS Expr1
FROM Test4
GROUP BY "PoorBehavior"
PIVOT Format([poorbehav],"mmm") In
("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug"," Sep","Oct","Nov","Dec");

You could create similar queries for the other three dates, and then union
each of the four queries together like the following:

Select * FROM QueryPB
UNION
Select * FROM QueryFW
UNION
Select * FROM QuerySW
UNION
Select * FROM QueryCon;

--
David Lloyd
MCSD .NET
http://LemingtonConsulting.com

This response is supplied "as is" without any representations or warranties.
<ca**********@newcastle.gov.uk> wrote in message
news:11*********************@g43g2000cwa.googlegro ups.com...
Hi,

I'm back with the same question as I still can't get it to display
my data the way I want it to.

The table lists information about a perpetrator involved with an anti
social behaviour order. The table contains personal information about
the individual as well as (here is where the letter dates comes in:)
e.g.

Surname:
Forename:
DOB:
Address1:
Address2:
Address3:
Address4:
PostCode:
Date Poor Behaviour Letter Sent: 01/04/05
Date First Warning Letter Sent: 10/04/05
Date Second Warning Letter Sent: 20/04/05
Date Consult SS Letter Sent: 28/04/05
etc....
etc....

The structure of the system that surrounds this table is:

tblCase - this has a 1:M relationship with:
tblIncident - this has a 1:M relationship with:
tblIncidentPerpetrator

I would like a total of all letters sent to all perpetrators having
months across the top, the letter type down the left and a count/total
of them within, an example is shown below.

Jan Feb Mar Apr May
etc..
Date Poor Behaviour Letter Sent 30 15 10 43 12
Date First Warning Letter Sent 12 7 3 12 2
Date Second Warning Letter Sent 2 1 0 1 0
Date Consult SS Letter Sent 1 0 0 0 0

I have tried using a crosstab query (actually several of them) but
cannot get it to calculate and display the data the way I want it to.

I have even created a table containg the 12 months and tried to link it
to a query that shows my results as months instead of dates using:
format([<<Field>>],"mmm")

I have ran out of ideas and not even sure if what I'm trying to do is
possible using a query or crosstab. I may have to create an individual
query and report for each letter and put them all as subreports into
one report so that they appear on 1 page as 1 report.

Any help would be appreciated.

Regards.

CJB
Nov 13 '05 #2
Hi David,

Thanks for the help, it worked a treat.

I was originally trying to do this as a couple of queries but obviously
not possible as I need one for each letter.

Thanks again.

Cheers.

CJB

David Lloyd wrote:
Carl:

One approach is to create a crosstab query for each of your four dates and
then union the four queries together to get the final query results.

The crosstab for Poor Behavior might look like the following:

TRANSFORM Count(Test4.PoorBehav) AS CountOfPoorBehav
SELECT "PoorBehavior" AS Expr1
FROM Test4
GROUP BY "PoorBehavior"
PIVOT Format([poorbehav],"mmm") In
("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug"," Sep","Oct","Nov","Dec");

You could create similar queries for the other three dates, and then union
each of the four queries together like the following:

Select * FROM QueryPB
UNION
Select * FROM QueryFW
UNION
Select * FROM QuerySW
UNION
Select * FROM QueryCon;

--
David Lloyd
MCSD .NET
http://LemingtonConsulting.com

This response is supplied "as is" without any representations or warranties.
<ca**********@newcastle.gov.uk> wrote in message
news:11*********************@g43g2000cwa.googlegro ups.com...
Hi,

I'm back with the same question as I still can't get it to display
my data the way I want it to.

The table lists information about a perpetrator involved with an anti
social behaviour order. The table contains personal information about
the individual as well as (here is where the letter dates comes in:)
e.g.

Surname:
Forename:
DOB:
Address1:
Address2:
Address3:
Address4:
PostCode:
Date Poor Behaviour Letter Sent: 01/04/05
Date First Warning Letter Sent: 10/04/05
Date Second Warning Letter Sent: 20/04/05
Date Consult SS Letter Sent: 28/04/05
etc....
etc....

The structure of the system that surrounds this table is:

tblCase - this has a 1:M relationship with:
tblIncident - this has a 1:M relationship with:
tblIncidentPerpetrator

I would like a total of all letters sent to all perpetrators having
months across the top, the letter type down the left and a count/total
of them within, an example is shown below.

Jan Feb Mar Apr May
etc..
Date Poor Behaviour Letter Sent 30 15 10 43 12
Date First Warning Letter Sent 12 7 3 12 2
Date Second Warning Letter Sent 2 1 0 1 0
Date Consult SS Letter Sent 1 0 0 0 0

I have tried using a crosstab query (actually several of them) but
cannot get it to calculate and display the data the way I want it to.

I have even created a table containg the 12 months and tried to link it
to a query that shows my results as months instead of dates using:
format([<<Field>>],"mmm")

I have ran out of ideas and not even sure if what I'm trying to do is
possible using a query or crosstab. I may have to create an individual
query and report for each letter and put them all as subreports into
one report so that they appear on 1 page as 1 report.

Any help would be appreciated.

Regards.

CJB


Nov 13 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Donna Sabol | last post by:
First, I should start by saying I am creating a database to be used by some very impatient, non-computer literate people. It needs to be seameless in it's operation from their point of view. I...
1
by: Steve | last post by:
I have looked through the newsgroup for an answer to this but haven't been able to find anything resembling my situation. What I want to do is relatively simple, I think. I have a crosstab...
4
by: Judy | last post by:
I'm using Access 2003 and was wondering if it is possible to have a paramater selection within a crosstab query so that I wouldn't need to build a new table. I have a select query that I'm using...
6
by: carl.barrett | last post by:
Hi, I have a table that Stores individual records about a person and the dates that a number of letters were sent to them, e.g. Date First Letter Sent: 01/04/05 Date Second Letter Sent:...
2
by: Claus Haslauer | last post by:
Hi, I want to create a crosstab query that looks like this Date | Elevation 1 | Elevation 2 | ... ______________________________________________________________________ Date 1 | xx.y | xx.y...
14
by: Tina | last post by:
My employer tracks productivity/performance of clinicians (how much they bill) each week, its averages for the month, and the 6 months. These averages are compared to their expected productivity....
5
by: Wired Hosting News | last post by:
I tried to be breif and give a scenario so as not to be overlooked because it was soooo long. Let me give you real world. I am a manufacturer of goods and produce 11 items that are distributed...
2
by: sixdeuce62 | last post by:
Hello, I am trying to create a query that will prompt me to enter the parameter value if beginning date and ending date. I have created everything I need in the query, but I have to manually go...
8
by: Paul H | last post by:
I want to base a form on a crosstab query. The query shows statistics for a user defined period. The column headings will look something like this: ClientID Month01 Month02 Month03 etc.. ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
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...
0
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...
0
jinu1996
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.