473,382 Members | 1,425 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,382 software developers and data experts.

Crosstab Query

ddtpmyra
333 100+
Hi I have below crosstab query inside MS Access. The result is the sum of new msg are group by month. But there are results that rows are null how can I tell my query to display only rows that has both columns are not null? I hope I explain this very well and below are sample of my results and wanted result.

Current Sample Result:
Mailbox
Expand|Select|Wrap|Line Numbers
  1.           01/2011    02/2011
  2. 001        12        null
  3. 002        45        05
  4. 003        12        10
  5. 004        null      30

Result wanted:
Expand|Select|Wrap|Line Numbers
  1. 002      45     05
  2. 003      12     10
Here's my current code
Expand|Select|Wrap|Line Numbers
  1. TRANSFORM Avg(STATISTICS.[New Msg Count]) AS [AvgOfNew Msg Count]
  2. SELECT STATISTICS.Mailbox
  3. FROM STATISTICS
  4. WHERE (((STATISTICS.[New Msg Count])>=1))
  5. GROUP BY STATISTICS.Mailbox, STATISTICS.[New Msg Count]
  6. PIVOT STATISTICS.MontDate;
  7.  
Mar 3 '11 #1

✓ answered by beacon

Hi ddtpmyra,

I struggled with this problem when I first started working with Crosstab queries, but found that you have to create a separate SELECT query that includes all the values you want and eliminates the null values. Once that query is created, you would include that query in the Crosstab query.

Hope this helps,
beacon

4 1044
beacon
579 512MB
Hi ddtpmyra,

I struggled with this problem when I first started working with Crosstab queries, but found that you have to create a separate SELECT query that includes all the values you want and eliminates the null values. Once that query is created, you would include that query in the Crosstab query.

Hope this helps,
beacon
Mar 3 '11 #2
ddtpmyra
333 100+
Thanks! That was the last I'm thinking of (smile)
Mar 3 '11 #3
ddtpmyra
333 100+
Anybody who can help me to transform my Access Query to MS SQL query?

Expand|Select|Wrap|Line Numbers
  1. TRANSFORM Avg(Qry_Statistic.[New Msg Count]) AS [AvgOfNew Msg Count]
  2. SELECT Qry_Statistic.Mailbox, First(Qry_Statistic.[Average Msg Length]) AS [Avg Msg Length], First(Qry_Statistic.[Oldest Msg Date]) AS [Odest Msg], Last(Qry_Statistic.[Folder Msg Count]) AS [Not New Msg], Last(Qry_Statistic.[Total Msg Count]) AS [Total Msg], Last(IIf(STATUS![Last Log On] Is Not Null,STATUS![Last Log On],"NEVER")) AS [Last Log On], Last(STATUS.[Mailbox Comment]) AS [LastOfMailbox Comment]
  3. FROM Qry_Statistic INNER JOIN STATUS ON Qry_Statistic.Mailbox = STATUS.Mailbox
  4. WHERE (((Qry_Statistic.[New Msg Count])<>0 And (Qry_Statistic.[New Msg Count]) Is Not Null))
  5. GROUP BY Qry_Statistic.Mailbox, Qry_Statistic.Mailbox
  6. PIVOT Qry_Statistic.MontDate;
  7.  
Mar 3 '11 #4
ddtpmyra
333 100+
Here's another dilema I'm having (sigh)

If I have a result like this:
Expand|Select|Wrap|Line Numbers
  1.           01/2011    02/2011 
  2. 001        12        null 
  3. 002        03        05 
  4. 003        11        03 
  5. 004        null      03
  6.  
And I wanted to display the rows result that has > 10 and not null for either coloumns for 01/2011 or 02/2011
Result Desired:
Expand|Select|Wrap|Line Numbers
  1.           01/2011    02/2011 
  2. 003        11        03 
  3.  
Result Explanation:
003 is the only row to be displayed because Jan has > 10 value which is 11 the rest are either doesn't have >10 value or the value are null

Current Query:
Expand|Select|Wrap|Line Numbers
  1. TRANSFORM Avg(dbo_Raw_Statistics.[New Msg Count]) AS [AvgOfNew Msg Count]
  2. SELECT dbo_Raw_Statistics.Mailbox
  3. FROM dbo_Raw_Statistics INNER JOIN dbo_Raw_Status ON dbo_Raw_Statistics.Mailbox = dbo_Raw_Status.Mailbox
  4. WHERE (((dbo_Raw_Statistics.Mailbox)<>"0") AND ((dbo_Raw_Statistics.[New Msg Count]) Is Not Null))
  5. GROUP BY dbo_Raw_Statistics.Mailbox
  6. PIVOT dbo_Raw_Statistics.MonthDate;
  7.  
  8.  
Mar 4 '11 #5

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

Similar topics

3
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...
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...
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...
3
by: Bryan | last post by:
I've been looking over this newsgroup, but I can't find an answer to my problem. I see that a few others have posted this issue over the years, but none of them got a response. I'll give it...
2
by: Nenad Markovic | last post by:
Hi everybody, When executing a Crosstab Query I see only rows (defined in a row heading) that have values (defined in value field) in at least one column (defined as column headings). How can...
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....
6
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...
3
by: russellhq | last post by:
Hi, I'm fairly new to access and have a little trouble with a crosstab query I've setup. I have a main form where the user selects a project name and below in a subform, a crosstab query is...
4
by: m.wanstall | last post by:
I have a crosstab query that compiles data for Months of the year. I have a stacked select query on top of that crosstab query that uses the latest 2 months data and exports it to a fixed length...
2
by: Jim Devenish | last post by:
I wish to create a crosstab query as the record source for a report. It needs to count data between selected dates which are entered by the user in a popup window. The following Select query...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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:
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 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.