473,587 Members | 2,490 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Crosstab Query to display all possibilities, even if zero

20 New Member
First of all I'm new to the forum and am working on my first database. So far I think I've done not too bad but have hit a stumbling block for which I'm not sure how to get around.

What I have is a database which tracks assigned files to a certain people which is generated by a form and then recorded into a table. Tables are as follows “Staff” “Loss_Type” and “Claims_Assignm ent”.

From this “Claim_Assignme nt” table I have created separate queries that provide summary reports sorted by certain predetermined dates. IE: week, month, year

From this I have designed (2) crosstab queries from the “Q:Claims_Assig n_Year” to return results from which I want to create report. One crosstab query is staff vs. type and the other is type vs. staff.

What I would like is (1) query that displays all 26 “Staff” vs. All 22 “Types” in one report.

What was happening was when I joined “Staff” from the table and “Staff” from the Query Summary all the staff would be listed.

As soon as I joined “Loss_Types” from the table to the Yearly Summary Query, I receive an error about ambiguous joins.

As a result I created (2) queries since I could not get (1) query to display all 26 “Staff” vs. All 22 “Loss_Type” in one report.

What I 'd like to see is "Q:Claims_Assig n_Year_Adj vs. Type" display all possible “Staff” vs. all possible “Loss_Type” even if results equal zero for one or both variables.

From reading different info I assume I'm to use a NZ() function, but not sure how or if this is the approach required.




Q:Claims_Assign _Year SQL:

Expand|Select|Wrap|Line Numbers
  1. SELECT Staff.[Last Name], Staff.[First Name], Loss_Type.[Type of Loss], Claim_Assignment.[Assigned Date]
  2. FROM Start_End, Loss_Type INNER JOIN (Staff INNER JOIN Claim_Assignment ON Staff.[Last Name] = Claim_Assignment.[Last Name]) ON Loss_Type.[Type of Loss] = Claim_Assignment.[Type of Loss]
  3. WHERE (((Claim_Assignment.[Assigned Date]) Between [Start_End]![Year Start Date] And [Start_End]![Year End Date]))
  4. ORDER BY Staff.[Last Name];

Q:Claims_Assign _Year_Adj vs. Type SQL:

Expand|Select|Wrap|Line Numbers
  1. TRANSFORM Count([Q:Claims_Assign_Year].[Assigned Date]) AS [The Value]
  2. SELECT Staff.[Last Name], Staff.[First Name], Count([Q:Claims_Assign_Year].[Assigned Date]) AS [Total Of Assigned Date]
  3. FROM [Q:Claims_Assign_Year] RIGHT JOIN Staff ON [Q:Claims_Assign_Year].[Last Name] = Staff.[Last Name]
  4. GROUP BY Staff.[Last Name], Staff.[First Name]
  5. PIVOT [Q:Claims_Assign_Year].[Type of Loss];

Q:Claims_Assign _Year_Type vs. Adj SQL:

Expand|Select|Wrap|Line Numbers
  1. TRANSFORM Count([Q:Claims_Assign_Year].[Assigned Date]) AS [The Value]
  2. SELECT Loss_Type.[Type of Loss], Count([Q:Claims_Assign_Year].[Assigned Date]) AS [Total Of Assigned Date]
  3. FROM [Q:Claims_Assign_Year] RIGHT JOIN Loss_Type ON [Q:Claims_Assign_Year].[Type of Loss] = Loss_Type.[Type of Loss]
  4. GROUP BY Loss_Type.[Type of Loss]
  5. PIVOT [Q:Claims_Assign_Year].[Last Name];
Mar 23 '07 #1
1 3705
nico5038
3,080 Recognized Expert Specialist
Assuming you have a tblStaff and a tblLossType, you can create a select query like:

select StaffID, LosType from tblStaff, tblLossType

This will force all combinations to appear.
This query can be used with the other table in an OUTER (Left or Right) join to create your crosstable query with all fields filled.

Getting the idea ?

Nic;o)
Mar 24 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
11482
by: John | last post by:
I've read several prior posts in this group about using nz() to convert null values to zero; however, I'm not sure how/where to implement this function in my crosstab query. The crosstab query (qryPromoFilm_NetCM_Crosstab) uses another query (qryPromo_NetCM) as its source. The crosstab is used to show revenue spread out through the twelve...
1
17652
by: Nathan Bloomfield | last post by:
Does anyone know if there is any documentation which relates to Access2k + ? or can anyone help adjust the code? I am having trouble converting the DAO references. TITLE :INF: How to Create a Dynamic Crosstab Report PRODUCT :Microsoft Access PROD/VER:1.00 1.10 OPER/SYS:WINDOWS
2
2244
by: carl.barrett | last post by:
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.
2
2928
by: deejayquai | last post by:
Hi I'm trying to produce a report based on a dynamic crosstab. Ultimately i'd like the report to actually become a sub report within a student end of year record of achievement. The dynamic sub-report will capture what grades the student has achieved in a list of different subjects and the reason I need it to be dynamic is that students...
6
4453
by: tizmagik | last post by:
I am having a lot of difficulty generating a CrossTab Query based report. I have looked online for several tutorials and whatnot but I have not been able to really find what I'm looking for, nor have I been able to adapt other people's solutions/tips to fit what I need. If anyone could please help me with the following it would be really...
13
17127
by: salad | last post by:
Operating in A97. I didn't receive much of a response conserning Pivot tables in Access. Pivot tables are nice, but a CrossTab will work for me too. Using a Pivot table, one is actually launching Excel for data viewing. I'd prefer the user stay in Access. Creating dynamic crosstab queries is pretty simple. The problem is that the column...
5
2919
by: bruce24444 | last post by:
What I have is a database which tracks assigned files to a certain people which is generated by a form and then recorded into a table. Table are as follows “Staff” “Loss_Type” and “Claims_Assignment”. From this “Claim_Assignment” table I have created separate queries that provide reports sorted by certain predetermined dates. IE: week,...
1
4083
by: bobykim | last post by:
Hi All, I'm using MS Access 2003 in a Windows XP environment. I've created an aging report for my department that is based on what I call the "Main query" with an IIf statement that allows the user to define the dates into 30 day aging segments. Then I've created a crosstab query which counts the results. How I'd like the report to...
10
2022
kcdoell
by: kcdoell | last post by:
I have a listbox on a form that uses my crosstab query to display the query results. For the fields that display numbers, the numbers with a zero in the last digit are being dropped. Example $88.80 is displayes as $88.8. I have the field set as a numeric/double. The interesting thing is that the raw data file has the zeros on the end. I am...
0
7923
marktang
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7852
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8216
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7974
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6629
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5395
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3845
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
2364
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 we have to send another system
0
1192
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.