'Add New Column to Query with Default Value

I have added a blank column to my query, so when I export the results the user can use the blank column to manually input their drivepath to use for their mailmerge automation. The code below achieves that.

SELECT
     NULL as WordDocPath

I want to take this one step further by adding the drive path text as the Null Column's default value so the user doesn't have to copy and paste 10k rows on the exported file.

How do I add the drivepath (C:\Users...) as a default value, text formatted?

While I'm at it.. would also like to add a FileName column the combines the text from other existing columns.

Example:

SELECT
     Lastname
     EmployeeID
     Region

Result wanted: Doe_123456_REGION_LetterTitle
The Letter Title is not pulled from the table, it's just a text string.



Solution 1:[1]

%dw 2.0
output application/json
var grp = payload groupBy (item, index) -> item.id
---
grp mapObject ((value, key, index) -> 
    {
        id: key,
        qty: (value map ($ - "id"))
    }
)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 machaval