Home > Blockchain >  Add New Column to Query with Default Value
Add New Column to Query with Default Value

Time:05-20

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.

CodePudding user response:

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

By selecting it, instead of null:

select 'C:\Users...' as drivepath 
from ...

add a FileName column the combines the text from other existing columns

That's concatenation.

select lastname ||'_'|| employeeID ||'_' || 'LetterTitle' as result
from ...
  • Related