MS SQL Queries Adding Table Columns

Hi all,

I’m not very Jython savvy. I have data that I am pulling from a dataset and I want to add columns to the table after I have pulled that data. I want to do this because I want to calculate some things from the data and display the results of those calculations in a new column. I have tried the ALTER TABLE function and it does not appear to work. I have also tried to add into the SELECT statement as:
COUNT(CASE WHEN (EXAMPLE)=’ ’ then null else 1 end) Passed.
However, when I try to run this it gives me an error that it doesn’t recognize the CASE statement.

This is a copy/paste of my current code.

SELECT Infeed_Pick_Time, HMC_Place_Position, Reject_Place_Time, Telesis_Pick_Time, Outfeed_Place_Time
COUNT(CASE when Telesis_Pick_Time=’’ then null else 1 end) Passed
FROM Table
WHERE Infeed_Pick_Time >= DATEADD(day,-7, GETDATE())

I want to add a column/rows for the new data that I calculate but it won’t let me.

Not sure about the query, but I can link you to a post where I did something similar.

The syntax needs to be fixed:

select CASE Telesis_Pick_Time when '' then null else 1 end as Passed from table

if you’re trying to do count, you’ll need to include a group by at the end on how it should count the data.

1 Like