Skip to content

Tag: sql-server

Why does my SQL query not have any columns?

I’m not an expert by any means but I write SQL queries fairly regularly. I am pulling data via Crystal Reports 2013 from SQL Server 2016 (not positive about the version). Just as an aside, CR permits parameters so that’s what {?DateStart} is. {?DateStart} and {?DateEnd} are regular dates, {?Servic…

Find groups that are missing values of one column

Hopefully someone can send some light on an issue I’m trying to resolve. Types Codes I would like to be able to determine those Code/ID pairs that are missing a particular type. The result of this query should yield. Answer You need conditional aggregation for this: Another option is to cross join the p…

Match column name with data from other table

I have dynamically created a temp table #temp1 that create column dynamically based on a json string. The table will look like as below #temp1 ID Field FRUIT VEGE 1 Field1 A B 2 Field2 C D I would like to fill in the value column only in result table based on the #temp1 table, the field and type_id is