Solved

query a table to display data jan thru dec

Posted on 2013-05-17
7
331 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 100 total points
Comment Utility
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 119

Accepted Solution

by:
Rey Obrero earned 400 total points
Comment Utility
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
Comment Utility
I think the Cross-tab looks better...
crosstabEXA1.accdb
0
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 
LVL 1

Expert Comment

by:chrisezard
Comment Utility
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
Comment Utility
Please evaluate capricorn1's post first.
He is much better at Crosstabs/SQL than I am...
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
Comment Utility
...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
Comment Utility
thanks cap and boag for explanation- sorry to take time getting back
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

728 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now