Skip to content
Advertisement

Tag: sql-server

Function to REPLACE* last previous known value for NULL

I want to fill the NULL values with the last given value for that column. A small sample of the data: In this example, the NULL values should be 1089066 until I reach the next non-NULL value. I tried the answer given in this response, but to no avail. Any help would be appreciated, thank you! EDIT: Sorry, I got

Convert rows to columns in SQL Server 2008

We have one table called Licenses. This is what it looks like: CustNum LicenseAddress License ExpiryDate 155 123 Y32CA 12/31/2018 155 998 Y32CB 12/31/2020 155 568 Y32CC 12/31/2022 Here is what I want it to look like: LicAddr1 Lic1 ExpiryDate1 LicAddr2 Lic2 ExpiryDate2 LicAddr3 Lic3 ExpiryDate3 123 Y32CA 12/31/2018 998 Y32CB 12/31/2020 568 Y32CC 12/31/2022 Here is the query I

Finding Active Clients By Date

I’m having trouble writing a recursive function that would count the number of active clients on any given day. Say I have a table like this: Client Start Date End Date 1 1-Jan-22 2 1-Jan-22 3-Jan-22 3 3-Jan-22 4 4-Jan-22 5-Jan-22 5 4-Jan-22 6-Jan-22 6 7-Jan-22 9-Jan-22 I want to return a table that would look like this: Date NumActive

Advertisement