Viewing 15 posts - 1,126 through 1,140 (of 13,838 total)
That made it more complicated than I had expected and I had to adopt a different method, unfortunately containing cascading CTEs. Does this get you close?
WITH BaseData1
AS...
September 28, 2022 at 6:35 pm
Which column, or columns, of data should be considered when generating the Sales = 0 rows?
September 28, 2022 at 1:46 pm
Well done on providing the sample data, though please use one or more code blocks next time. In future, please use temp tables (avoids others having to create and drop...
September 28, 2022 at 9:04 am
OK, I see the problem. The query logic is such that the generation of a notional Sales = 0 row depends on column 'Data', not on EmpId.
In the case where...
September 28, 2022 at 8:48 am
Are you saying that the line in blue is incorrect?
September 27, 2022 at 3:24 pm
Yes there is.
SQLPackage /Action:Publish, with appropriate parameters.
Set the CreateNewDatabase flag to false.
September 27, 2022 at 3:19 pm
That looks trivial and is something which I suggest you attempt yourself.
Just add the columns to the BaseData CTE and then to the SELECT ... FROM BaseData.
September 27, 2022 at 12:14 pm
Please read this article. The FORMAT() function performs very badly.
September 26, 2022 at 10:27 am
Like this?
SELECT t.VID
,t.OrdDate
,t.Prg1
,NewCol = (CASE
...
September 25, 2022 at 5:11 pm
Your query does not parse (it has two WHERE clauses). But no matter, for (current) YTD, use something like
WHERE SomeDate >= DATEFROMPARTS(YEAR(GETDATE()),1,1) AND SomeDate <= GETDATE()
September 25, 2022 at 4:08 pm
We use a third party tool 'ControlM' to create jobs, execute them since we have hundreds of jobs which run everyday so the ask is to run the job...
September 24, 2022 at 10:29 am
The refinements continue!
WITH BaseData
AS (SELECT Data = ISNULL(t.Data, LAG(t.Data, 1, NULL) OVER (ORDER BY rt.yearwk))
,Week = rt.yearwk
...
September 24, 2022 at 10:22 am
Using aliases for table names is also a good idea. Shortens the query and improves readability.
Any one of those left joins could be increasing the number of rows returned beyond...
September 23, 2022 at 9:57 am
Is it so difficult to use code blocks?
SELECT dbo.TrainingHeader.TrainingID
,dbo.TrainingHeader.TrainingNumber
,dbo.TrainingHeader.TrainingTypeID
,dbo.TrainingHeader.TrainingParticipantType
...
September 23, 2022 at 9:42 am
Try this (as my query gets uglier and uglier!):
WITH BaseData
AS (SELECT Data = ISNULL(t.Data, LAG(t.Data, 1, NULL) OVER (ORDER BY rt.yearwk))
...
September 22, 2022 at 2:54 pm
Viewing 15 posts - 1,126 through 1,140 (of 13,838 total)