I am using MS Access DB it has a table named 'tssStockMaster' with fields (PartNo, ItemName,Stock,Workshop) as shown in the image with following data.
Now I am unable to write a query in MS Access Database using SQL to get the following output such that the stock quantity is shown for each workshops against each item name(group by PartNo).
Since we cant use PIVOT in MS Access how can I achieve this ?
If you know up front how many workshops will be there and the number isn't significant I bet you could use aggregate function with if conditions:
select
partno
, itemname
, sum(iif(workshop = 'W101', stock, 0)) as w101
, sum(iif(workshop = 'Z239', stock, 0)) as z239
from t
group by partno, itemname
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.