Including Columns With No COUNT Values In Crosstab Query.

May 6, 2007

I have a columns that do not incur a count value within the time period of my query, yet i still want them to be displayed with a 0 or no value in the query view, how do i do this?

View Replies


ADVERTISEMENT

Sum Of 2 Columns In SELECT Including NULLs

Oct 5, 2005

Hi!
I want to add two columns a and b. However, there are rows in which EITHER a OR b is NULL. This should be handled as if the cell would be zero. Is there any way besides filling in 0s in the tables?

I tried
SELECT a, b,
IIF( a = NULL, b, IIF(b = NULL, a, a+b))
AS c FROM

but this doesn't work.

Any ideas?

Cheers
Tom

View 1 Replies View Related

Query Using Count, Maybe Crosstab?

Jun 28, 2005

Hello,

I am trying to simulate the data as it is presented in Excel, but with Access. This might sound stupid, but I have to draw a chart in Excel by Automation from the data I retrieve in Access. So far, I have made a query, which returns the following (see SourceData.jpg (http://www.access-programmers.co.uk/forums/attachment.php?attachmentid=10335&stc=1))

What I have to do next is present the data as follows (see ResultData.jpg (http://www.access-programmers.co.uk/forums/attachment.php?attachmentid=10336&stc=1))

How do I do this in SQL? I have a book at home which I am sure explains this in the form of a Count function, or a crosstab query, but will only be able to check it on Thursday. Could somebody maybe suggest something in the meantime?

What I do know, is that the bottom “Summe” row cannot be done by one query. But the column “Total” must be able to be done with a Count function. (Or am I wrong?) :confused:

Its so hot and humid here and no air-con that I cannot think, so please help!!!

J

View 4 Replies View Related

Queries :: Crosstab Query - Formatting User Defined Columns

Jul 24, 2013

I am making a classic sales over time crosstab query.

Rows: Customers
Columns: Sale months

Sales date is defined by the ETD of the order.

However, with the simple Format([ETD],"yyyy-mm") I get regular months, but I need to adjust the months to be between the 21st and 20th rather than 1st to 31st(30th).

August would be 7/21/2013 to 8/20/2013
September 8/21/2013 to 9/20/2013

Is it possible to format the columns this way?

View 2 Replies View Related

Queries :: Sort Crosstab Query Columns And Generate Report

Jul 28, 2015

This is a query, report and vba question. I'm using Ms Access 2007.

TABLE 1: projectname, activityname, totalhoursworked, employeename
TABLE 2: employeename, employeelevel
TABLE 3: employeelevel, rate

I created a select query to join the info that I need.

SELECT QUERY 1: projectname, activityname, employeename, totalhoursworked, rate, cost (calculated field (totalhoursworked*rate))

I have 2 crosstab queries.

CROSSTAB QRY 1: ROW (projectname, activityname) COLUMN (employeename) VALUE (totalhoursworked (summed))
CROSSTAB QRY 2: ROW (projectname, activityname) COLUMN (employeename) VALUE (cost (summed))

I then created a 2nd select query with inner joins to join both crosstab queries on similar fields (activity & projectname).

SELECT QUERY 2: projectname, activityname, employeename (totalhoursworked as value), employeename (calculatedcost as value)

It gives me this:

However, I want it like this:

Those employeename... refers to more employees being added after a period of time. Hence I want to know if I could use vba to generate a report every time a button is pressed on a form? I know how to link the form to the query.

View 8 Replies View Related

0 Values Ina Crosstab Query

Aug 3, 2005

Hi, I have a crosstab query, but for any product that has no entries on a certain date a NULL value is put in its place. Is there a way to have a 0 display there? Example of NULL:


DatePRODAPRODBPRODCPRODDPRODE
08/01/200513633
08/02/2005112643
Aug Total:216276



See how there is a NULL for 8/1 under PRODB? I would like that to be a 0

View 4 Replies View Related

Crosstab Query With TEXT Values?

Nov 14, 2007

This is almost a cross-forum post. I started a post in the reports forum to see if it were possible to sort/group the data by field values. Everyone knows this can be done row-by-row, but I was looking for a way to do it horizontally as well.


...........[quarter]="Fall".....[quarter]="Winter"........[quarter]="Spring"........[Quarter]="Summer"
2005.....Relevant Fields........Winter Stuff..................Spring stuff................Summer Stuff
|
2006
|
2007

It should look something like that where the years are values of [year] field and the seasonal quarters are values of [quarter] field.

I have been searching for something that will help me do this when I ran across information on the "crosstab" query. This, in principal is what I am looking for BUT I am not dealing with numeric data here. Is there still a away to make a crosstab query/report with text fields where there would normally be numeric data?

View 9 Replies View Related

Queries :: Expression Or SQL To Count Query Columns?

Jan 7, 2014

I'm looking for an expression or SQL for use in a query that will count the number of columns in another query. I do not need to count the records, I just need to know how many columns. I can't seem to locate a reference to a column count - everything points me to record count.

View 13 Replies View Related

Modules & VBA :: If No Selection Made Show All Values Including Null?

Sep 4, 2014

I have a Form with multiple comboboxes and listboxes whose selections are assembled into a query. The combo-box selection goes into an IF-ELSE statement for a selection check (IsNull) and if there is no selection made, it is supposed give me all values (Blanks & Non Blanks)

Here is a sample of my code:

Code:
If IsNull(Me.cbReg.Value) Then
RegStrng = " Like '*'"
Else
RegStrng = Me.cbReg.Value
RegStrng = "= " & RegStrng
End If

I have several If-Else statements here and a final query assembly at the bottom of the code page which is as follows

Code:
MasterSql = "SELECT DISTINCT blah-blah-blah" & _
" INTO some more blah-blah" & _
" FROM even more blah-blah-blah" & _
" WHERE dbo_mytable.[Reg#]" & RegStrng & _
" AND the results from other If-Else statements similar to above"

Here is where the problem comes in:

I see the mistake in my If-Else statement

Code:
If IsNull(Me.cbReg.Value) Then
RegStrng = " Like '*'"

Like * means it will show me all rows where there are NON-Blanks. However, it skips all Blank Data.

What should the If IsNull() statement look like if I want to show all the values?

If there was only one combo-box and there was no selection made, then the resultant query should show me all results rather than only the results where there is some sort of data within the column filtered by the combobox.

View 2 Replies View Related

Compare Values Of Columns Within The Same Query Table

Nov 19, 2006

Hi,
I am trying to compare two columns' values within the same QUERY table, but I kept on getting the "Data type mismatch in criteria expression" error. What am I doing wrong?

Here is my Select Query Statement:
SELECT qryDedparmDedetail.EMP_ID, qryDedparmDedetail.[Employer Amt], qryDedparmDedetail.[Employer Actl], qryDedparmDedetail.[Admin Amt], qryDedparmDedetail.[Admin Actl], qryDedparmDedetail.[Employee Actl], qryDedparmDedetail.[Employee Amt], qryDedparmDedetail.FirstOfSTATUS, qryDedparmDedetail.FirstOfAGENCY, qryDedparmDedetail.FirstOfTITLE, qryDedparmDedetail.FirstOfFORMAT_NM, qryDedparmDedetail.RepUnit, qryDedparmDedetail.FirstOfDEDTYPE_CD1 AS Expr1, qryDedparmDedetail.SumOfNBR, RepUnit.REPUNITDESC, qryDedparmDedetail.LeftType
FROM qryDedparmDedetail LEFT JOIN RepUnit ON qryDedparmDedetail.RepUnit = RepUnit.REPUNIT
WHERE (((qryDedparmDedetail.[Employer Amt])<>"Employer Actl") AND ((qryDedparmDedetail.LeftType)="01"));

View 2 Replies View Related

Multiple Columns For Crosstab

Dec 13, 2005

hi

is it possible to have multiple columns within a crosstab query??

if so please specify how. at the moment i am not allowed to specify column heading for more than one item

thanks

View 1 Replies View Related

CrossTab With Defined Columns

Dec 28, 2005

:D I am trying to create a CrossTab query from a table of expenses:

tblExpenses:
PropertyID
ExpenseType
Amount

There are many kinds of Expense Types. I want to use ExpenseType as the column header, BUT I want there to be 3 categories "Rent Expense," "Taxes," and "Other."

HOW do I group all expense types <> "Rent Expense" and "Taxes" in the third column?

I can get a comprehensive query with many columns, or set criteria to get just "Rent Expense" and "Taxes" columns, but I cannot get the 3 columns.

How can I do this? Thanks for your help!!

:confused:

View 1 Replies View Related

Queries :: Crosstab To Convert Rows To Columns

Sep 16, 2014

I have data like:

Code:

SubjectID VisitID VisitNum VisitDate VisitDetail Rspns
1 5 1 2/10/2001 Fever_1 Yes
1 5 1 2/10/2001 Age_1 12
2 7 1 5/08/2010 Fever_1 No
2 7 1 5/08/2010 Age_1 18
2 8 2 9/30/2010 Fever_2 Yes
2 8 2 9/30/2010 Age_2 18
etc.

I need to convert it to a non-normalized wide format, like this:

Code:
SubjectID VisitDate_1 Fever_1 Age_1 VisitDate_2 Fever_2 Age_2
1 2/10/2001 Yes 12
2 5/08/2010 No 18 9/30/2010 Yes 18
etc.

If I didn't have to worry about the VisitDate, a simple crosstab would do the trick:

Code:
TRANSFORM First(MyTable.Rspns) AS FirstOfRspns
SELECT MyTable.PatientID
FROM MyTable
GROUP BY MyTable.PatientID
PIVOT MyTable.VisitDetail;

View 1 Replies View Related

Queries :: Building Crosstab For Logic To Evaluate 2 Columns

Jul 17, 2013

Record Primary Key: ID_Wells..The TxtFedStCo has Fed, St, Co, ... in one field - and a Dt_Apd_Sub (date submitted) .There can be zero or many dates submitted for each Fed or State.

Objective:
If
A Fed has (1 or many) date submitted
AND
A St has (1 or many) date submitted
Condition is TRUE

How do I get to the next step? The reason for doing this in SQL is to prototype in Access, then move this over to TSQL later.

View 1 Replies View Related

Reports :: Crosstab Report With Dynamic Number Of Columns?

Mar 21, 2015

I've made a crosstab query and would like to use it to create a subreport. In the column headers I have names of courses. Courses can be added or removed. How can I make a crosstab report with dynamic columns?

PHP Code:

TRANSFORM Count(tblCourses.CourseName) AS CountOfCourseName
SELECT tblNmscStaff.NmscStaffFirstName, tblNmscStaff.NmscStaffLastName, 
tblNmscStaff.PtOrFtNtl, tblNmscStaff.Ntl, tblNmscStaff.NmscID
FROM tblNmscStaff LEFT JOIN (tblCourses RIGHT JOIN [tblNmscStaff/CoursesPointer] ON 
tblCourses.CourseID = [tblNmscStaff/CoursesPointer].CourseID) ON 
tblNmscStaff.NmscStaffID = [tblNmscStaff/CoursesPointer].NmscStaffID
GROUP BY tblNmscStaff.NmscStaffFirstName, tblNmscStaff.NmscStaffLastName, 
tblNmscStaff.PtOrFtNtl, tblNmscStaff.Ntl, tblNmscStaff.NmscID
PIVOT tblCourses.CourseName; 

View 1 Replies View Related

Creating Multiple / Sequential Crosstab Columns From One Field

Jan 3, 2013

Number of Operators per Permit

Permit
Operator Name
6
065-24088
EOG RESOURCES INC
6
065-24088
PDC MOUNTAINEER LLC

[code]....

I want to take this data and create six new columns (operator1; operator2; operator3; operator4; operator5; operator6) for each permit number so that each unique operator name will be housed in each of those six columns, with the rows being defined by the permit number. So, I want to produce something that looks like this...

Permit

operator1
operator2

[code]....

At present, there are as many as 6 operators per permit, but the number of operators per permit varies from 1 to 6. I included an example that has 5 operators, to show that I want the sixth column to be null in this instance. So if a permit had only one operator, only the operator1 field would take on a non-null value in the new table/query.I know how to do this with 2 operators per permit by using min/max or first/last functions in a query, but I don't know how to deal with more than two operators per permit.

View 4 Replies View Related

Modules & VBA :: Total Count Of Unique Values In A Query

Jan 13, 2015

I have the following code:

Code:
Dim rs As DAO.Recordset
Dim db As Database
Dim strSQL As String
Set db = CurrentDb
strSQL = "SELECT DISTINCT tbl_contract_lev.ContractID FROM (tbl_leverancier_gegevens INNER JOIN

[Code] ....

The result of the query is a list fo unique values but by including the "count" function in SQL seems not te be working in combination with "DISTINCT"...

View 5 Replies View Related

Query From (and Including) Date - Thru (and Including) Date

Jun 16, 2006

Access 2000
Hi All.

I am running a select query on a date field.

I populate the table "date" field from a Microsoft Date and Time Picker Control 6.0(SP6).
I havent been able to figure out how to ONLY populate the date portion of the control so my field value containes Date & Time.

When I run the query, I have to select the day after my request to include the records I need. I think this is because of the time in the field
Example, If I want all records thru 6/17/2006 I must select "thru" 6/18/2006. This mucks things up if I have records dated 6/18/2006

Both of these statements give the same bad results:

Between [forms]![freports]![from] And [forms]![freports]![thru]

>=[forms]![freports]![from] And <=[forms]![freports]![thru]

Any ideas?
TIA
Detrie

View 1 Replies View Related

Queries :: Fixed Heading Names In Crosstab With Dynamic Columns

Jul 3, 2014

I'm trying to run a query which fetches only the last 2 years of data for a given region from a table with several years worth of data (there are year, region, sector and rank columns among others). The region is passed into the query from a combobox from Form1.

The first problem was that some regions have up-to-date data and some not so much e.g. for Europe the "last 2 years" mean 2012,2013 for Asia its 2011,2012. In order to deal with this I've created a crosstab query which works well except for one thing - because the columns are dynamic (dependant on the region) the column headings change as well.

And here comes my question, how can i fix the column names to be e.g."Current Year" and "Prior Year" independent of the query fetching 2012,2013 or 2009,2010? I've tied different things with PIVOT... IN ... but with no luck.

Here's the sql for the query:

Code:

PARAMETERS [Forms]![Form1]![cmbRegion] Text ( 255 );
TRANSFORM min(DataTable.Rank)
SELECT DataTable.Region, DataTable.RegionalSector,
FROM DataTable
WHERE (((DataTable.Region)=Forms!Form1!cmbRegion))

[Code] ....

View 7 Replies View Related

Crosstab Values

Nov 28, 2007

Don't worry, this isn't about parameters. I've searched the forum and can't find the answer to this (but loads on crosstab perameters!).

I have a table:

DateWorked | StaffPIN | StartTime | FinishTime | ShiftType
------------|-------- -|-------- --|-----------|----------
.01/11/07....|..1234.....|...07:00....|....19:00....|.... .Day
.01/11/07....|..5678.....|...19:00....|....07:00....|.... .Night
.02/11/07....|..1234.....|...07:00....|....19:00....|.... .Day
.02/11/07....|..5678.....|...07:00....|....07:00....|.... .Sick

I want to turn this in to a report with the format:

DateWorked | 1234 | 5678 |
-------------|------|------|
..01/11/07....|..12...|...12...|
..02/11/07....|..12...|....S...|

Where the values (12, S) are the number of hours worked for that staff member on that day or a summary of what they did.

I have created a Function:

WorkedHours(DateWorked, StaffPIN)

This returns the number of hours worked by a saff member on a perticular day as an int.

I know I need to use a crosstab. My 1st attempt had [DateWorked] as the row heading, [StaffPIN] as column heading and the expression "expr: WorkedHours([DateWorked],[StaffPIN])" as the value with 'expression' as the crosstab property. It kept throwing the error "Data type mismatch in criteria expression". There are no Null fields in the table it's performing the query on.

For my 2nd attempt I created a simple query that had the fields I needed for the crosstab plus the extra field "Hours: WorkedHours([DateWorked],[StaffPIN])". I could then use a crosstab query on this simple query to create something aproaching the table I need. This new crosstab had [DateWorked] as the row heading, [StaffPIN] as the column heading, [Hours] as the value with 'Last' as the crosstab property.


1. Do I have to use a seperate query to calculate the WorkedHours() or can I do it in the crosstab?

2. I don't want the crosstab to average, sum or count etc. the data. I just want it to display the hours worked but I have to choose something in the crosstab properties. What do I select? (I selected 'Last' and it seems to work but I'm not sure why)

3. How do I get it to display something other than the number of hours worked for certain shift types? (I have all the shift types in a table with a flag for the ones that need to be calculated, the absence of this flag would mean it needs to show a summary eg 'S' for a sick shift, 'H' for a holiday shift)

I know I've asked for a lot of help recently, I really appreciate everyone's help. :D

View 9 Replies View Related

Query Not Including All Data

Jul 31, 2006

I currently have a query set up to pull information from 4 linked tables: Event, Readers, Class and School. The Event table contains a ClassID and a ReaderID. If everything has been assigned properly, there's no problem. If there's no reader assigned to ReaderID I still want the event details to be included in the output. Right now it's not. I'm pretty new to Access so if anyone can help, that'd be great. If you need to be try to explain further, let me know.

View 4 Replies View Related

Crosstab With Null Values

Aug 9, 2005

I currently have a crosstab query that compares data for two years. The results look like this.

month 2004 2005
January 98% 95%
.....
Decemeber 98

What I am getting at is that the query returns null values for the fields that do not have data recorded for the months in 2005 because we have not reached them yet. Is there a way for me to make sure that at least the value 0 is entered in the null value areas?

View 2 Replies View Related

Including Details From Query Calculation

Aug 1, 2006

Part of a database I'm developing stores details of events. Each event is funded from a variety of different sources.

There are three tables involved in making this work:
tblEvents - which stores the main event details
tblFundingOptions - which stores all the possible funding sources
tblEventFunding - which links the two together.

I have created a form to access all of this, with the information from tblEvents at the top and the Funding details on a subform.

I have created a query based on tblEventFunding which adds up the total amount of funding allocated to each event. I want to display this total on the form I've developed.

Can I do this without creating a second subform to pull the details in from the Query? I've tried creating a text box and linking it to the appropriate query, but it just displays #Name! - presumably because it doesn't know which record from the Query it should display, and I don't know how to tell it!!

Is what I'm trying to do possible, or do I need another subform?

Many thank in advance,

Gary

View 1 Replies View Related

Queries :: Including (In Between) Information In Query?

Sep 3, 2013

I have a table of events that includes fields for ages, a Start Age and a End Age.

I want to make a query that pulls up how many programs have been provided to a given age group. How can I make it so that the query will understand to include records that have the given age group in between the Start Age and End Age fields? I.e. if I set the query to 3rd Grade, records that start at 2nd Grade and end with 4th Grade are included in the results as well.

View 7 Replies View Related

Tables :: Count Unique Values With Different Values

Feb 7, 2014

i have one table in which ID is Primary ID with Different Values

Like

ID NAME PAN
1 A X
1 B Y
1 A X
2 C Z
2 C G
3 D U

it shows that ID 1 having 2 Name (A& B,with PAN, X & Y ,respectively).how can i get this that ID having More than 1 Value like 1 and how can i select only these records ID which having more than 1 value and how can i update values for 1 ID.

View 8 Replies View Related

Null Values In Crosstab Queries

Apr 24, 2006

Hi there, instead of blank fields in my crosstab query, and hence my report, i would like a standard comment, such as 'No Booking'.

My crosstab is something like this:

.........A...........B..............C............. D
1.......X

2.......X..........................X

3...................X............................. .X

(Ignore the dots, obviously)

Currently, when i try to open the report based on this query, it fails unless each column has data in it for at least one record.

I've tried using the Nz function but haven't been able to make it work. Thankyou in advance! :)

View 5 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved