Sorry hard to figure out the subject.
I have following SQL query which needs to be converted to MS Access. Since Access doesnt have row_number() or it is used with transform, I cant get the desired results. Is there some workaround to get same results.
Original table/query result:
Next SQL query:
[SELECT *
FROM (SELECT d.loc_area,
d.loc_rack,
d.loc_height,
d.loc_place,
d.locvrc,
row_number() OVER(PARTITION BY d.loc_area, d.loc_rack, d.loc_place
ORDER BY d.loc_height) rn_pivot
FROM (select locvrc,
SUBSTR(stoloc, 0, 2) loc_area,
SUBSTR(stoloc, 4, 2) loc_rack,
SUBSTR(stoloc, 6, 1) loc_place,
SUBSTR(stoloc, -2) loc_height
FROM locmst) d)
PIVOT (MAX(loc_height) AS EXT, MIN(locvrc) AS UNIQ FOR rn_pivot IN ('1' AS HEIGHT_1, '2' AS HEIGHT_2, '3' AS HEIGHT_3, '4' AS HEIGHT_4, '5' AS HEIGHT_5, '6' AS HEIGHT_6, '7' AS HEIGHT_7, '8' AS HEIGHT_8))
ORDER BY LOC_AREA,
LOC_RACK,
LOC_PLACE]
It gives me nice pivot where it summarize three first row and lay down rest 2columns (height, locvrc) in the same row:
Question is how to do this in Access. Im linking my sql table to Access table and try to perform the query from that table. Transform which Im trying:
TRANSFORM First(loc_height) AS FirstHeight
SELECT loc_area, loc_place, loc_rack
FROM
(SELECT
loc_area,
loc_place, loc_rack,
loc_height
FROM tbl_labels
)
GROUP BY loc_area, loc_place, loc_rack
PIVOT loc_height
It does the job, but outcome is not what is required. Also this is missing the locvrc, cant get the multiple value to work:
There is blanks, or the height is now in the columns and it shows all height that is in query.
Any idea how to convert this to similar what in SQL?
Thanks a lot in advance!
Br Jan