Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
Access
3rdpartyusrgrp
access
activexcontrol
adp.sqlserver
commandbarsui
conversion
dataaccess.pages
developers.toolkitode
devtoolkits
externaldata
forms
formscoding
gettingstarted
internet
interopoledde
macros
modulescoding
modulesdaovba
modulesdaovba.ado
multiuser
odbcclientsvr
queries
replication
reports
security
setupconfig
tablesdbdesign
  
 
date: Tue, 26 Aug 2008 23:27:00 -0700,    group: microsoft.public.access.queries        back       


Format Report   
Hi, how do it translate this data 

ID-----NAME-----COUNT-----LOC
10-----PETE-----300----------NORTH
10-----PETE-----20-----------EAST
10-----PETE-----5------------WEST
15-----JACK-----20----------EAST
15-----JACK-----10----------SOUTH

into this format

ID-----NAME-----TOTAL_COUNT-----COUNT_LOC1-----LOC1-----COUNT_LOC2-----LOC2----COUNT_LOC3-----LOC3
10-----PETE-----325----------------------300---------------NORTH----20-----------------EAST-------5-----------------WEST
15-----JACK-----30-----------------------20-----------------EAST------10----------------SOUTH------0-----------------na
-

Cheers
date: Tue, 26 Aug 2008 23:27:00 -0700   author:   Prav

RE: Format Report   
You could create a cross-tab query, although your column headings would read 
(ID, Name, Total_Count, North, South, East, West.

1. Start out by creating a new query.

2. Pull in the ID, Name, Count, LOC and Count (yes, add this one twice) 
fields to your query.

3. Change the query to a Crosstab query.  In the query grid, you will now 
have rows labeled Field, Table, Total, and Crosstab.   These rows should look 
like:

Field:   ID                Name            Count      LOC           Count
Table:
Total: Group By        Group By       Sum        Group By     Sum
Crosstab:Row          Row              Row        Column       Value

Actually the table row will contain your table name, and the Crosstab row 
will read "Row Heading" or "Column Heading"

If you want the locations to show up in a particular order, you will need to 
add a Pivot clause to the end of the query, which should look similar to:


TRANSFORM Sum(Count) AS Count_Total
SELECT ID, Name, Sum(Count) AS Total_Count
FROM tbl_Test
GROUP BY ID, Name
PIVOT LOC In ("North","South","East","West");

BTW, [Name] is a reserved word in Access, and I would recommend not using it 
as a field name.  You might use [Name_First], [Name_Last], [Name_POC], 
[Name_Contact], [Name_Employee], or something like that, but I would strongly 
recommend against using reserved words as either table of field names.

-- 
HTH
Dale

Don''t forget to rate the post if it was helpful!

email address is invalid
Please reply to newsgroup only.



"Prav" wrote:

> Hi, how do it translate this data 
> 
> ID-----NAME-----COUNT-----LOC
> 10-----PETE-----300----------NORTH
> 10-----PETE-----20-----------EAST
> 10-----PETE-----5------------WEST
> 15-----JACK-----20----------EAST
> 15-----JACK-----10----------SOUTH
> 
> into this format
> 
> ID-----NAME-----TOTAL_COUNT-----COUNT_LOC1-----LOC1-----COUNT_LOC2-----LOC2----COUNT_LOC3-----LOC3
> 10-----PETE-----325----------------------300---------------NORTH----20-----------------EAST-------5-----------------WEST
> 15-----JACK-----30-----------------------20-----------------EAST------10----------------SOUTH------0-----------------na
> -
> 
> Cheers
date: Wed, 27 Aug 2008 06:00:01 -0700   author:   Dale Fye

Re: Format Report   
A little bit different, using a crosstab:

TRANSFORM  LAST([count]) AS cell
SELECT id, name, SUM(cell) AS total_count
FROM yourTableName
GROUP BY id, name
PIVOT loc


will give


id        name    north    east    south    west     total_count
10        pete    300        20                       5        325
15        jack                    20         10                      30





Vanderghast, Access MVP



"Prav"  wrote in message 
news:DC9113F3-5D11-4BC7-904D-700DCBAFC943@microsoft.com...
> Hi, how do it translate this data
>
> ID-----NAME-----COUNT-----LOC
> 10-----PETE-----300----------NORTH
> 10-----PETE-----20-----------EAST
> 10-----PETE-----5------------WEST
> 15-----JACK-----20----------EAST
> 15-----JACK-----10----------SOUTH
>
> into this format
>
> ID-----NAME-----TOTAL_COUNT-----COUNT_LOC1-----LOC1-----COUNT_LOC2-----LOC2----COUNT_LOC3-----LOC3
> 10-----PETE-----325----------------------300---------------NORTH----20-----------------EAST-------5-----------------WEST
> 15-----JACK-----30-----------------------20-----------------EAST------10----------------SOUTH------0-----------------na
> -
>
> Cheers
date: Wed, 27 Aug 2008 09:04:38 -0400   author:   Michel Walsh vanderghast@VirusAreFunnierThanSpam

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us