Viewing 12 posts - 1 through 12 (of 12 total)
You could also move the CASE statement into a CROSS APPLY to calculate the newAmount.
SELECT
ca.newAmount
, ca.newAmount + t.Adjust as TotalAmount
From...
January 21, 2022 at 8:04 pm
In my company's case we use that date of 2078-12-31 as the maximum date because there are fields in some tables that are defined as SMALLDATETIME and since the maximum...
February 27, 2021 at 5:37 am
Ken, that is some pretty neat code. I had to tweak it just a bit to support a scenario that I forgot to include in my original post.
The extra scenario...
February 26, 2021 at 10:01 pm
I completely forgot about trying the EXCEPT route. The method I was trying is similar to what you have by expanding the date ranges but my method of remerging the...
February 23, 2021 at 2:20 pm
You just need to change the INNER JOINs to FULL JOINs and change the a.id field in the SELECT portion to COALESCE(a.id, b.id, c.id, d.id) and give it the alias...
December 2, 2019 at 9:03 pm
You were almost there. You correctly parameterized the @localtable variable in the first field of the select. However, to ensure that the variables that you concatenate for the object names...
June 3, 2019 at 9:01 pm
Sergiy (10/5/2016)
SELECT CONVERT(TIME,CONVERT(SMALLDATETIME, @StartTime2))
Please be aware that when converting a DATETIME to a SMALLDATETIME that when the seconds are <30 the minutes will match but when the seconds are 30+...
October 11, 2016 at 3:55 pm
I can see that it works but what is the meaning of the time int value.
Here is an example of why I say it is stored as a float.
with cte...
November 25, 2014 at 4:15 pm
Ed Wagner (11/25/2014)
PHYData DBA (11/25/2014)
Brian.Klinect (11/25/2014)
That's exactly what I did. I had no idea I could use a negative number for a datetime!
Since DateTime is stored as an Integer,...
November 25, 2014 at 10:15 am
:ermm: Is it just me or are options 1 and 4 identical?
Option #1: FROM,ON,JOIN,WHERE,GROUP BY,CUBE | ROLLUP,HAVING,SELECT,DISTINCT,ORDER BY,TOP
Option #4: FROM,ON,JOIN,WHERE,GROUP BY,CUBE | ROLLUP,HAVING,SELECT,DISTINCT,ORDER BY,TOP
I chose option #1 and it looks...
November 10, 2014 at 9:43 pm
Ok, I just have to toss a wrench into the logic here.
Since we are talking about birthdays, what if the person is over 100 years old? This logic will...
August 8, 2014 at 10:17 am
You can use a recursive common table expression to achieve this.
DECLARE @startDate DATETIME = '8/1/2014'
DECLARE @endDate DATETIME = '8/31/2014'
DECLARE @dayOfWeek INT = 1 -- 1=Sun, 7=Sat
;WITH cte_Recursion AS
(
SELECT...
August 8, 2014 at 9:56 am
Viewing 12 posts - 1 through 12 (of 12 total)