Viewing 15 posts - 166 through 180 (of 1,396 total)
It seems like you're looking for an UPDATE statement
/* select using OUTER APPLY and TOP(1) */
select t.id, t.code, t.result, prev.result prev_result,
...
October 17, 2023 at 11:04 pm
...
In source table each row is allways for one date, so if the work shift continues over midnight it's broken into two parts. But for expected output the time...
October 17, 2023 at 3:47 pm
Thanks, Drew for your reply. Did you bother to read my latest post? and did you bother to run the query that I provided?
IF yes, then my question was...
October 12, 2023 at 5:58 pm
I also did a comparison of my query with Steve's query. Here are the read stats. Specifically note the scan counts and logical reads on the 'Worktable'.
Using the preceding...
October 12, 2023 at 5:28 pm
Afaik the set up is not clear. This seems to produce the correct result
with
gaps_cte as (
select *, case when crit<>lag(crit) over (order by...
October 12, 2023 at 2:29 am
This took a while, but was fun! There are a couple of characters in this forum who like to come along and make my code run 17 times faster,...
October 10, 2023 at 4:35 pm
... it assumes that you know in advance which of the columns has the most distinct items ('Line' in your example, but 'Division' in mine).
One way to generalize the...
October 7, 2023 at 6:18 pm
Ok the set up and explanation are appreciated. Right off the bat tho there's an issue (which is hopefully a typo) with the sample data. In the #tbl_transection table in...
October 3, 2023 at 2:33 pm
I want ...
Keep at it you're on the right track. Your query doesn't seem to return any error so what's the question? What's Wrong Output and Correct Output seems...
October 1, 2023 at 3:48 pm
It appears the math in your example calculation is off (by 300.00) beginning on line 3: instead of 21.37 should it not be 321.37?
select 21.37 + (11033.21)...
October 1, 2023 at 12:53 pm
Is x a column in table A? It seems so. The SQL language does not support dynamic join types or JOIN conditions derived within a WHERE clause based on CASE...
September 30, 2023 at 7:58 pm
There is probably a better method:
Well I came up with pretty much the identical query. Joining the rows back together using the array keys seems unavoidable. In SQL Server...
September 14, 2023 at 7:49 pm
If I'm understanding then perhaps an INSERT statement and an UPDATE statement. Possibly it could also be done using a MERGE statement however I don't use such syntactic sugar. Also,...
September 7, 2023 at 2:15 pm
Author Joe Booth gives SSC a nice mention in this YouTube video at about the 11:11 mark. The channel is Syncfusion which afaik is a .NET UI kit vendor (which...
August 25, 2023 at 4:34 pm
Curious, why not create 2, 4, or ?? procs instead? Instead of enums in C#, a UDT, and dynamic SQL could you not get rid of the parameterization and just...
August 19, 2023 at 12:54 pm
Viewing 15 posts - 166 through 180 (of 1,396 total)