In Query - Autofill new column

** :chug: :toast:

Hello Everyone. This might be very simple, but need some help. I get records from a query whose status is "Marked". I need another column to be added to result set which just says "Marked" for every record. Is that possible in query?**

You can add a column to the end of the SELECT list in your existing query. Alternatively you can keep the existing query unchanged and wrap it in an outer query like shown below:

SELECT
	*,
	'Marked' AS StatusColumn
FROM
(
	YourExistingQueryHere
) s

If you have an ORDER BY clause in your existing query, you will have to remove that and add that back at the very end. So on second thoughts, it is best to modify your existing query to include the Status column

1 Like

ERROR #50805215
Query failed to execute. GDS Exception. 335544569. Dynamic SQL Error
SQL error code = -104
Token unknown - line 1, column 9
, (comma)

My query is so simple.

SELECT
so.num AS ordernum, so.customercontact, so.dateissued, so.datecreated, so.datecompleted

FROM ship
LEFT JOIN so ON so.id = ship.soid
WHERE ship.statusid = 20

"Marked" as status worked. Thanks so much.