Viewing 15 posts - 736 through 750 (of 1,403 total)
You could unpivot both tables and inner JOIN them. Here's an example based on another forum question/answer. Something like this
drop table if exists #tTableA
go
create table #tTableA(
...
February 3, 2021 at 7:26 pm
It was very quick, and I knew about it yesterday, but didn't really do much other than give a vote to try. Still amazed it happened.
Comments, suggestions, feedback on...
February 3, 2021 at 2:26 pm
The queries ends up wrapping a DataReader in .Net 5, which although technically are created to handle SELECT statements better, still works perfectly for also INSERT/UPDATE/DELETE statements, but you...
January 31, 2021 at 1:53 pm
It's an interesting approach. There are a few questions that jump out tho. There's no mention of how DML statements like INSERT/UPDATE/DELETE are handled? Could it execute stored procedures? How...
January 30, 2021 at 9:23 pm
You know that the LAST_VALUE() is NEVER going to be before the CURRENT ROW, so it's completely unnecessary to specify the beginning of the window as UNBOUNDED PRECEDING when...
January 29, 2021 at 2:20 pm
This is sort of confusing because the ORDER BY of the outermost query includes the 'head' column as well as 'Trans_ID'. The SUM OVER ORDER BY is only by '(select...
January 26, 2021 at 8:13 pm
This comes really close. It uses a FULL JOIN which is functionally both a LEFT JOIN and a RIGHT JOIN. It seems the example Status_ToolType column might have some consistency...
January 24, 2021 at 10:17 pm
Maybe the correlated subquery in the WHERE clause is converting your LEFT JOIN into an INNER JOIN. Maybe try expressing OBS as OUTER APPLY SELECT TOP(1) ... instead.
January 24, 2021 at 6:08 pm
Why call it "spoofing" and not "mocking"? Is spoofing mocking? Is mocking spoofing?
January 20, 2021 at 3:37 pm
Instead of approximating the "current" date by selecting the MAX(date) the code could reference CAST(GETDATE() as DATE) to access the system datetime and cast it as type DATE.
January 18, 2021 at 6:14 pm
Ugh it's dependent on calculated row values. Although painful to create, here's a WHILE loop which populates a new table '#myNewTable' with the ID and the derived theoretical_cycle column. It's...
January 15, 2021 at 3:06 am
Does it also restart at 0 when aggregating the days?
January 14, 2021 at 10:26 pm
The 'max_val' column matches the 'Days_Cycle' column in the table provided. The 'theoritical_cycle' (in rows where ID is greater than 19) doesn't seem to follow the rules you're suggesting
January 14, 2021 at 7:21 pm
Integer division comes in handy when creating groupings based on ranges of integers, aka "buckets". Something like this
select t.*, v.*, cycle.*
from #mytable t
...
January 14, 2021 at 5:33 pm
Viewing 15 posts - 736 through 750 (of 1,403 total)