Skip to content
Advertisement

Tag: tsql

Convert different dates in date column to rows in SQL Server

I want to display different dates as columns from LOGDATE column. Here are the details My query: This query returns this result: Expected output format: I have multiple types of SERVICE_TYPE and SERVICE_NAME, not just the three sown in the sample. How can I get my expected output? Any help would be appreciated. Answer You can do conditional aggregation to

SQL Server Lag and Lead

I’m using SQL Server 2014. I have a table: I have some data: If I perform a LAG and LEAD using the below for one Job, I get the desired result: Result: Notice the NULL for the first FromActionCode and LastToCode, which is correct. However, If I look at all records, it messes it up: What am I missing? Answer

Week number and its Sunday

I have a simple question. If I have a week number, how I assigned a Sunday to it? (In t-sql) For example. I have number 15 as input (which is week from 8.4. to 14.4., from monday to sunday), and I will need it to be shown as 14.4. as output. The things is, that I have a column of

Advertisement