|
Here's a SELECT-only version of the same thing, i.e. to pivot the distance-measuring query by Strahler order. The number and name of the result columns must be specified explicitly here (the TRANSFORM version has the advantage on that score). SELECT [ID], [Geom (I)], FIRST(IIf([STRAHLER] = 1, [D], NULL)) AS [1], FIRST(IIf([STRAHLER] = 2, [D], NULL)) AS [2], FIRST(IIf([STRAHLER] = 3, [D], NULL)) AS [3], FIRST(IIf([STRAHLER] = 4, [D], NULL)) AS [4], FIRST(IIf([STRAHLER] = 5, [D], NULL)) AS [5], FIRST(IIf([STRAHLER] = 6, [D], NULL)) AS [6], FIRST(IIf([STRAHLER] = 7, [D], NULL)) AS [7] FROM (SELECT [W].[ID], [W].[Geom (I)], [S].[STRAHLER], MIN(Distance([W].[Geom (I)], [S].[Geom (I)])) AS [D] FROM [Wetland Centroids Inner] AS [W] CROSS JOIN [Streams_drvdc ARC Drawing] AS [S] GROUP BY [W].[ID], [W].[Geom (I)], [S].[STRAHLER] ) GROUP BY [ID], [Geom (I)]; So far, then, either version produces the result table that was needed. Getting the results into the original table requires an UPDATE query. The SELECT query can be "wrapped" (using an extra join), or its result table can be included by reference. The result of the TRANSFORM query must be specified by reference. Mike, I'm learning quite a bit too. There's been a certain amount of thinking out loud on my part, which I hope no one minds. Any questions about how this stuff operates would be welcome since they'd make me think differently about it.
|