I attempted to use Transform and Cleanse to add a calculated column to data that I queried.
STAND | SECTION | SETN | ST_POSITION | ROLLID |
---|---|---|---|---|
0 | PLAIN | 1 | BOTTOM | 90245 |
0 | PLAIN | 1 | TOP | 90940 |
0 | PLAIN | 2 | BOTTOM | 80258 |
0 | PLAIN | 2 | TOP | 80799 |
I need to create a new table that contains STAND, SECTION, SETN and the new calculated column which is a NVARCHAR that consists of SECTION + 'another string'; I modified the original query to provide distinct values.
SELECT DISTINCT ROLL_LIST.STAND, ROLL_LIST.SECTION, ROLL_LIST.SETN
FROM GSL_PI_DEV.PISystem.ROLL_LIST ROLL_LIST
WHERE (ROLL_LIST.STAND IS NOT NULL)
AND (ROLL_LIST.SECTION IS NOT NULL)
AND (ROLL_LIST.SETN IS NOT NULL)
ORDER BY ROLL_LIST.STAND ASC, ROLL_LIST.SECTION ASC, ROLL_LIST.SETN ASC
It produced this result set:
STAND | SECTION | SETN |
---|---|---|
0 | PLAIN | 1 |
0 | PLAIN | 2 |
0 | PLAIN | 3 |
0 | PLAIN | 4 |
I sent the results to Transform and Cleanse (T&C). I added the calculated column. However, when I exported the transformed data set to Excel, the spreadsheet contained duplicate rows. Essentially, T&C ignored the DISTINCT query and produced the results for the original (non-distinct) dataset.
Did I miss something when working with T&C?
I repeated this process again but instead of using DISTINCT I grouped by the three columns that I wanted:
SELECT ROLL_LIST.STAND, ROLL_LIST.SECTION, ROLL_LIST.SETN
FROM GSL_PI_DEV.PISystem.ROLL_LIST ROLL_LIST
WHERE (ROLL_LIST.STAND IS NOT NULL)
AND (ROLL_LIST.SECTION IS NOT NULL)
AND (ROLL_LIST.SETN IS NOT NULL)
GROUP BY ROLL_LIST.STAND, ROLL_LIST.SECTION, ROLL_LIST.SETN
ORDER BY ROLL_LIST.STAND ASC, ROLL_LIST.SECTION ASC, ROLL_LIST.SETN ASC
I used T&C to create the calculated column and this time when I exported, the file contained only the rows shown in the result set.
In order to use DISTINCT in the first query, I edited the query in Toad Data Point's query builder and "visualized it" back to the diagram. I couldn't find the change in the diagram so potentially, T&C referenced the diagram and recreated the result set when it exported the transformed information.
STAND | SECTION | SETN | ROLLSET |
---|---|---|---|
0 | PLAIN | 1 | PLAIN |
0 | PLAIN | 2 | PLAIN |
0 | PLAIN | 3 | PLAIN |
0 | PLAIN | 4 | PLAIN |
0 | PLAIN | 5 | PLAIN |
10 | PLAIN | A1 | PLAIN |
10 | PLAIN | A2 | PLAIN |
10 | PLAIN | A4 | PLAIN |
10 | PLAIN | A6 | PLAIN |
10 | PLAIN | A7 | PLAIN |
2 | M3104 | 2 | M3104 |
2 | SE | D1 | SED |
2 | SE | D2 | SED |
2 | SE | D5 | SED |