Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

query a table to display data jan thru dec

Posted on 2013-05-17
7
Medium Priority
?
343 Views
Last Modified: 2013-05-18
Hello,
have attached sample db with tbl1
Is there a way I can create query on tbl1 and display solution like this:

Item #    Item Desc    Total    January   February   March    April    May   June  etc..
01           Misc            2879     880        888           780       331
03           PC               2983     672        488          1188      635
05          etc....
thank you
EXA1.accdb
0
Comment
Question by:davetough
7 Comments
 
LVL 74

Assisted Solution

by:Jeffrey Coachman
Jeffrey Coachman earned 400 total points
ID: 39176038
That is either a Pivot Table or a Crosstab query.

There is a crosstab query wizard in Access to help with the crosstab

You can make a Pivot table as well by changing the "View" of the table to "Pivot Table"

Then dragging and dropping the fields wherever you want them to be.

You will have to play around with both methods to see which is best for you...

But also wait for another expert to come along to give more explicit instructions.
0
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 1600 total points
ID: 39176054
copy and paste this sql statement in the SQL view of a query


TRANSFORM Sum(tbl1.[Total #]) AS [SumOfTotal #]
SELECT tbl1.[Item #], tbl1.[Item Desc], Sum(tbl1.[Total #]) AS [Total Of Total #]
FROM tbl1
GROUP BY tbl1.[Item #], tbl1.[Item Desc]
PIVOT tbl1.[Month] In("January","February","March","April","May","June","July","August","September","October","November","December")


run CrosstabQuery
EXA1.accdb
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 39176071
I think the Cross-tab looks better...
crosstabEXA1.accdb
0
Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

 
LVL 1

Expert Comment

by:chrisezard
ID: 39176072
You need a Crosstab Query, which will give you a spreadsheet-like layout

1.Click on Create/Query Design
2.Close the Show Table window
3.Right click on Query1 and select SQL view
4.Copy this code

TRANSFORM Sum(tbl1.[Total #]) AS [SumOfTotal #]
SELECT tbl1.[Item #], tbl1.[Item Desc], Sum(tbl1.[Total #]) AS YTD
FROM tbl1
GROUP BY tbl1.[Item #], tbl1.[Item Desc]
PIVOT tbl1.Month;

5.Right click on Query1 and select Design
6.Save the query as qtabMonthlyTotals, or whatever suits you
7.Run the query

8.The columns will not display in calendar order, but you can move them when the results are displayed and they will stay in the order you set.
9.You may want to format the values in design view
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 39176075
Please evaluate capricorn1's post first.
He is much better at Crosstabs/SQL than I am...
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 39176080
...and his post will sort the Months properly...
(My post will have the months sorted by the name alphabetically...)
:-(
0
 

Author Closing Comment

by:davetough
ID: 39177505
thanks cap and boag for explanation- sorry to take time getting back
0

Featured Post

Fill in the form and get your FREE NFR key NOW!

Veeam is happy to provide a FREE NFR server license to certified engineers, trainers, and bloggers.  It allows for the non‑production use of Veeam Agent for Microsoft Windows. This license is valid for five workstations and two servers.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

972 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question