Viewing 15 posts - 61 through 75 (of 4,087 total)
This gives the exact same results as Jonathan's but only reads the near and next term data tables once each.
SELECT FP.UNDERLYING_SYMBOL,
...
April 2, 2024 at 6:46 pm
The problem with your question, is that you've not given enough data to rule out potential incorrect queries. For example, SELECT * FROM dbo.history
returns the correct results for your...
April 2, 2024 at 6:24 pm
You need multiple OPENJSON
functions.
select j.WorkId, r.[Busket Rule], r.Exit_Window, r.Startegy, r.Start_Date
from openjson(@json)
with (
WorkId int '$.WorkId',
OverrideRules NVARCHAR(MAX) '$.UpdateAttributes.OverrideRules' AS JSON
) j
CROSS APPLY OPENJSON(j.OverrideRules)
WITH (
[Busket Rule] varchar(200) '$."Busket Rule"',
Exit_Window...
April 2, 2024 at 5:53 pm
This gives the exact same results as Jonathan's but only reads the near and next term data tables once each.
SELECT FP.UNDERLYING_SYMBOL,
...
April 2, 2024 at 5:36 pm
One more thing. There is no reason to use an explicit CAST
here, and using an implicit CAST
makes it much easier to read.
/* Explicit CAST ...
April 1, 2024 at 3:41 pm
Please clean up your code before posting. There are several issues with the code for your test data.
April 1, 2024 at 3:28 pm
The problem is that you haven't defined "total up" and "total down".
Is it a change on the field "up"? If so, your data is incomplete. A value can be up,...
March 26, 2024 at 4:34 pm
This query produces the exact same results as your query with far fewer reads.
WITH Order_Statuses AS
(
SELECT h.order_number
, h.order_date
, q.[label]
, q.orderstatus_src
, q.orderstatus_tgt
, h.order_status
...
March 26, 2024 at 3:21 pm
For future reference, many people are wary of opening random files from the Internet. If you want help, please post a script to create a TEMP table and insert the...
January 30, 2024 at 9:32 pm
You can't generally define aliases INSIDE expressions.
Drew
PS: You're dates don't match.
December 28, 2023 at 6:20 pm
Yes, that's a bit shorter and generally more efficient. I'm wondering if there were a lot more that 12 items per customer and the right indexes on the table...
December 26, 2023 at 3:09 pm
;WITH CTE AS
(
SELECT DISTINCT CustomerCode
FROM myTable
)
SELECT B.*
FROM CTE A
CROSS APPLY(SELECT TOP(12) *
...
December 21, 2023 at 7:25 pm
Nested CASE
expressions are very hard to read, because it quickly becomes difficult to tell exactly where you are in the nesting. Here is an example that uses a single...
December 21, 2023 at 3:40 pm
00000 is an integer, so you are explicitly converting your value to char, but then implicitly converting it back to integer when you add it to 00000. You want to...
December 5, 2023 at 7:14 pm
update #leadtest set [gamedate] = (select Lead([gamedate], 1) OVER( ORDER BY [gamedate] ASC))
LEAD is a windowed function - what makes you think it is going to...
December 5, 2023 at 4:16 pm
Viewing 15 posts - 61 through 75 (of 4,087 total)