Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

query a table to display data jan thru dec

Posted on 2013-05-17
7
Medium Priority
?
342 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 
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

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

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

AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
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 …
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

715 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