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

Crosstab Query Issue

77
Hi Guys,

I'm back with another question this time.. Stuck again :-(

Here's what I'm trying to do..

I have a table with three fields namely Emp_ID (Text), RDate (Date/Time), FShift (Text)

For every employee, I have 14 Records defining their roster for any given week; 2 Records for any given date defining their start & end time.

I need to output the following format in Excel:
Expand|Select|Wrap|Line Numbers
  1. EMPID;RDATE1;RDATE1;RDATE2;RDATE2;RDATE3;RDATE3;RDATE4;RDATE4;RDATE5;RDATE5;RDATE6;RDATE6;RDATE7;RDATE7; 
RDATE is the column header which will be replaced with the respective date (Rdate Column Entries)

All goes fine till here...

I wrote a crosstab query to achieve this as under:
Expand|Select|Wrap|Line Numbers
  1. TRANSFORM First(tmpTMS.FShift) AS FirstOfFShift
  2. SELECT tmpTMS.EMP_ID
  3. FROM tmpTMS
  4. GROUP BY tmpTMS.EMP_ID
  5. PIVOT tmpTMS.rdate;
  6.  
But this doesn't give me the duplicate column for the same date as required and also omits the data to be present in the second column.

Any suggestions please?
Oct 7 '08 #1
1 1824
Stewart Ross
2,545 Expert Mod 2GB
Hi Yaara. Although I'm not entirely clear on the format you want from your crosstab, such a query cannot repeat column headers in the way you describe.

The column header acts like a Group By clause to bring all duplicates together into a single unique value under which the pivoted aggregate values will be placed. Crosstabs simply cannot give you repeated columns, any more than you can have a repeated row in a SELECT DISTINCT query.

If you think about it a bit more, how could Access distinguish one occurrence of the date 01/01/2008, say, from any other? If it could, how would it know to give you just two values?

Although Access can display pivot tables in the same way as Excel does, it does not have a pivot table query that allows multiple-column pivoting of data. It is a weakness of the type of crosstab query provided that only one column can be pivoted.

It is possible to use self-joins on the table or query concerned to provide at least some of what you want, but to come up with suitable SQL for this we'd need a bit more detail on the content of the table or query concerned and how the dates follow each other - so if you could post some example data along with how you envisage the result data to look this would be very helpful.

If it turns out that SQL is unsuited to the task it is always possible to use bespoke processing of recordsets to do so - but it's then getting quite complicated if this is the only way forward that would meet your needs.

-Stewart

ps when you mention 14 records for a roster, does this mean some form of repeated record group? If it is, such a repeated group breaks first normal form table design. This may just have been shorthand for something else, but if you are using a non-relational table for rostering purposes it makes it difficult (and in some cases impossible) to use relational queries to extract meaningful data.
Oct 7 '08 #2

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

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: 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...
2
by: Sherman H. | last post by:
I have a few questions for crosstab and popup form questions: 1. I created a crosstab as follows: IT Financial Operation John 21 22 ...
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...
7
by: newguy | last post by:
I am trying to get the totals of a table by client by type of income. This query will get what I am looking for with each unique combination as a row: SELECT Sales.Client, BillCode.Type,...
8
by: Penny | last post by:
(Access 2003 Multiuser Split DB, Windows XP Pro) Hi All, I would really appreciate just some basic tips on how to make a Crosstab Form based on a Crosstab Query. The query always has the same...
1
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...
2
by: Ecohouse | last post by:
I'm using Access 2002. I'm creating a report dynamically using a crosstab query. I found the code for this on the Microsoft site. I noticed that the report doesn't go past six pages. How can I...
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: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: 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...
0
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,...
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
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,...

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.