I'm asked to select some columns from a table. One of which does not exist in the table. This column is called PayComment and I need to use a conditional to check if there is data in another separate column inside that table. If there is PayComment will say 'Yes' If there isn't it will say 'no'.
I'm confused on how to do this because I've only ever created a column using an alias([OldColumn] AS [NewColumn]) or declared it as a variable and INSERT it into the table. However I have to create this column/use a conditional to determine what's inside it, while keeping it in the select statement whilst I grab the other existing columns.
I know this is wrong but this is what I'm imagining
CREATE PROC spPayIncreaseListing
AS
SELECT FirstName, LastName, CONVERT(varchar, HireDate, 1) AS HireDate, PayRate,
CONVERT(varchar, StartDate, 1) AS PayRateStartDate, CONVERT(varchar, EndDate, 1) AS PayRateEndDate,
PayComment AS IF Work.COLA > 0
PayComment = 'Yes';
ELSE
PayComment = 'NO';
