Solved

Convert columnar data to rows

Posted on 2012-03-16
4
303 Views
Last Modified: 2012-06-27
Thank you for looking at my question,

I have a table that lists the output from manufacturing orders in the format:
Date, Order No, Order Qty, Processed Qty, Status

Where Destination could be 'GOOD', 'SCRAP', 'LOST' or 'QA'

For an order that results in all pieces having the same status the data would look like

16/03/2012, JOB001, 20, 20, GOOD (or SCRAP / LOST / QA as necessary)

Equally, you could get

16/03/2012, JOB002, 40, 20, GOOD
16/03/2012, JOB002, 40, 10, SCRAP
16/03/2012, JOB002, 40, 10, QA

I need to query this data and output one row per job no in the format

Date, Job No, Order Qty, Good Qty, Scrap Qty, Lost Qty, QA Qty

Ideally, where an order has all parts with the same status I would like all the other status quantities to be zero.


Any help you can offer will be greatly appreciated.
0
Comment
Question by:Crxfrd
4 Comments
 
LVL 53

Expert Comment

by:Dhaest
ID: 37728625
Did you try to add a "transpose" query ?
http://www.meadinkent.co.uk/acctranspose.htm


Can you give an overview of the tables where the data is coming from ...
0
 
LVL 39

Accepted Solution

by:
als315 earned 500 total points
ID: 37728732
Look example
DBtrans.mdb
0
 
LVL 8

Expert Comment

by:gpizzuto
ID: 37728764
SELECT Date, [Job No], max(Order Qty) as [Order Qty],
sum(iif(Status='GOOD',Order Qty,0)) as [Good Qty]),
sum(iif(Status='SCRAP',Order Qty,0)) as [Scrap Qty]),
sum(iif(Status='LOST',Order Qty,0)) as [Lost Qty],
sum(iif(Status='QA',Order Qty,0)) as [Qa Qty]
FROM YourTable
GROUP BY Date,[Job No]

Hope this helps (check sintax, I have not Access installed and cannot try)
0
 

Author Closing Comment

by:Crxfrd
ID: 37728769
Works Perfectly,

Thank you
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

Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
'Between' is such a common word we rarely think about it but in SQL it has a very specific definition we should be aware of. While most database vendors will have their own unique phrases to describe it (see references at end) the concept in common …
Familiarize people with the process of utilizing SQL Server stored procedures 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 Micr…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

863 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

21 Experts available now in Live!

Get 1:1 Help Now