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

INSERT INTO SELECT AND VALUES

Error: “Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.” Answer The error is pretty clear. The outer select returns too many rows. You can just remove it: Note that the constant values are included in the select.

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

Input selected row and ignore duplicate row

I have a problem that I need to insert a selected row from the table to another table based on last_update data or last_transaction_product. last_update is the data updated from the table, and last_transaction_product is the latest transaction from my shop, and then my row has duplicate data but has a different last_update column here, this duplicate data must not

Advertisement