472,352 Members | 1,670 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,352 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 2143
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...
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...
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...
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...
2
by: Claus Haslauer | last post by:
Hi, I want to create a crosstab query that looks like this Date | Elevation 1 | Elevation 2 | ......
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...
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...
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...
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:...
1
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
0
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the...

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.