Viewing 15 posts - 91 through 105 (of 4,080 total)
Listen to Jeff on this. He helped me out tremendously, as he has helped countless others.
__________________________________________________
Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills
November 14, 2019 at 4:56 pm
You first need to do some research on spatial concepts. You can only consider flight paths to be straight lines over very small distances. If you are flying...
__________________________________________________
Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills
November 7, 2019 at 4:42 pm
Could we by any chance look at the underlying CTE that you mentioned?
__________________________________________________
Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills
November 5, 2019 at 10:12 pm
Your solution will get the correct result, but it is running the entire First4Count_Cte twice. Basically generating a huge number of rows and then filtering them out. The...
__________________________________________________
Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills
November 5, 2019 at 10:09 pm
The PIVOT function will do what you want. You can also google for the old school way of doing a pivot. It's called a "Crosstab".
I find the syntax easier...
__________________________________________________
Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills
November 5, 2019 at 9:52 pm
This isn't pretty, but it seems to work.
The code assumes that '^' is a safe character to use to bookmark the position of the ending period. If not, pick another. ...
__________________________________________________
Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills
November 5, 2019 at 9:03 pm
It helps to remember that, in SQL, CASE is an expression, not a flow control statement. All CASE does is use if/then/else logic to produce a single value.
Your original logic...
__________________________________________________
Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills
November 5, 2019 at 8:21 pm
And this thread just keeps on keeping on...
This is a pure rant, so read at your own risk.
I have been involved in the interview process for a senior sql developer...
__________________________________________________
Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills
April 10, 2019 at 3:11 pm
declare @start date = '2018/08/01'
;with tally (N) as (select top 366 row_number() over(order by (select null)) from sys.columns c1 cross join sys.columns c2)
select Dateadd(day,N-1,@start)...
__________________________________________________
Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills
March 29, 2019 at 1:16 pm
Are you simply wanting to not include weekend days (Saturday, Sunday), or are you trying to find the previous BUSINESS day?
If you are looking for the previous business...
__________________________________________________
Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills
March 29, 2019 at 1:05 pm
If you aren't afraid of CTEs, use this syntax. 😉
;with cte1 as (select id, pro, [type]
, coalesce(qty1,lead(qty1,1) over(partition by pro, [type] order by modifieddate...
__________________________________________________
Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills
March 28, 2019 at 1:25 pm
Another variation. For a huge file, I hope there is a covering index on the Pro, Type, and Modified Date columns.
select id, Pro, [Type], Qty1,Qty2,...
__________________________________________________
Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills
March 28, 2019 at 1:20 pm
Jeff is indeed the MASTER OF THE TALLY TABLE.... and many other things besides. 😉
__________________________________________________
Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills
March 28, 2019 at 9:18 am
Not recursive at all, just a cte. But yes, it finds the first space from the right to pull the strings to be tested.
__________________________________________________
Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills
March 19, 2019 at 9:06 am
One more variation:
select #t.*
, case when right(Disposition,nullif(charindex(space(1),reverse(disposition)),0)-1)
in ('CH', 'HC', 'MA', 'NH', 'OA', 'OTH', 'PSY', 'SNF')
then right(Disposition,nullif(charindex(space(1),reverse(disposition)),0)-1) end as ShortCode
into #r2
__________________________________________________
Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills
March 15, 2019 at 4:08 pm
Viewing 15 posts - 91 through 105 (of 4,080 total)