October 28, 2015 at 10:31 am
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?:exclamationmark::exclamation:
October 28, 2015 at 10:33 am
chindilog (10/28/2015)
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?:exclamationmark::exclamation:
Sure. Just add [AnotherColumn] = 'Marked' to your SELECT list.
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
October 28, 2015 at 10:46 am
I get it. All rows shows marked but column name shows "constant", how do I change "constant" to "status"?
SELECT 'Packed', 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
October 28, 2015 at 10:49 am
chindilog (10/28/2015)
I get it. All rows shows marked but column name shows "constant", how do I change "constant" to "status"?SELECT 'Packed', 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
Use REPLACE() function or a CASE structure. Both are well documented in Books Online (SQL Server Help).
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
October 28, 2015 at 10:53 am
Is it the name of the column in your result set you want to change? If so, do it in the way Chris first suggested, or in the way you've done for your ordernum column. Best not to mix the two, though.
John
October 28, 2015 at 10:55 am
A simple - "Marked" as status , worked. Thanks so much.
October 28, 2015 at 12:05 pm
CAST('Marked' as varchar(20)) AS [XYZ]
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply