Solved

query a table to display data jan thru dec

Posted on 2013-05-17
7
337 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
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 400 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
Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

 
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

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)

Question has a verified solution.

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

In the previous article, Using a Critera Form to Filter Records (http://www.experts-exchange.com/A_6069.html), the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
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…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

820 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