Skip to content
Advertisement

Tag: sql-server-2008

SQL difference between cell values (LAG function not working)

Unfortunately I can’t use the lag function due to using SQL Server 2008. I need to find machine based difference between two values at different times. I have a table like that: I need to find a difference (76340-75000 = 1340) between id 1 and 3. Tried these before: but it compares with t1.id with the whole table. I can’t

Getting the correct data to be stored into temp table by comparing timerange

Currently, I need to get the correct data to be inputted into temp table. There are 3 datetimes that I need to compare. However not all values are populated. Example-Assume that all dates are the same Data1 DateTime1 DateTime2 DateTime3 First 2020-08-24 14:00:00.000 2020-08-24 14:30:00.000 2020-08-24 15:30:00.000 Second NULL 2020-08-24 13:00:00.000 2020-08-24 14:30:00.000 Third NULL NULL 2020-08-24 10:00:00.000 From the

group by category to show difference by month in SQL

I have a view that brings the total number of members in each class for each month however I want to show the growth by subtracting the total_count of the previous month with the current month in a separate column. For example, I would like to view the data as mentioned in the attached image. Here on that table, you

Advertisement