Viewing 15 posts - 166 through 180 (of 4,085 total)
I thought that I need to do just simple moving average
AVG([ONQTYCOGS]) OVER ( ORDER BY [WED] ROWS BETWEEN 52 PRECEDING AND CURRENT ROW ) ROLL1
but it doesn't return what...
J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA
January 6, 2023 at 5:14 pm
What happens if you use the following to avoid the function breaking sargability (assumption: tables are indexed to support the query)
AND (cp.from_service_date BETWEEN d.eff_from AND d.eff_thru...
J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA
December 22, 2022 at 6:39 pm
ISNULL() is not SARGable, so it should be avoided in WHERE clauses. You have three instances of ISNULL() in your WHERE clause. There are a couple of ways to remove...
J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA
December 22, 2022 at 6:01 pm
This is a packing intervals problem. You can Google "packing intervals" to find out more.
Here is a solution
/* Set up the sample data */
CREATE TABLE #Claims
(
...
J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA
December 22, 2022 at 3:10 pm
The likely issue is the order of processing. You have your COUNT inside your CASE when these should likely be reversed. Your CASE should be inside your COUNT.
If you want...
J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA
November 9, 2022 at 4:00 pm
My favorite project was converting our alumni/fundraising database system from a third-party mainframe product to a third-part SQL Server product. It was my first exposure to SQL Server. I wasn't...
J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA
November 1, 2022 at 6:06 pm
without giving you the code look at functions charindex, substring and reverse(use twice) - using these 3 you will be able to get that split
I believe that reverse is...
J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA
October 31, 2022 at 7:42 pm
Thanks for the reply, but that is not what I need.
I need a way to write this that when the state is MN then these ProcCodes are Excluded, but...
J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA
October 20, 2022 at 7:24 pm
Hi,
I am trying to put a case statement in a where clause and nothing that I am doing seems to work, that I got online.
Basically, I need to put...
J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA
October 20, 2022 at 2:28 pm
You are partioning on the same column that you do MIN/MAX on. This will not work. As I understand your requirements, you shouldn't do a PARTITION BY, since you...
J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA
October 12, 2022 at 1:53 pm
All expressions in a SELECT clause are evaluated at the same time. This means that you cannot use an alias in the same SELECT statement in which it is defined--which...
J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA
October 10, 2022 at 5:48 pm
A couple of things:
J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA
October 6, 2022 at 6:38 pm
This is as clear as mud. You've been around long enough to know that you should post sample data and expected results using (temp) table creates and inserts.
Also, what is...
J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA
October 6, 2022 at 3:20 pm
Here is a different approach. It's better on some metrics, but worse on others. I'm not sure which will play out better in the long run.
WITH TableBRanges...
J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA
September 29, 2022 at 4:09 pm
The key here is to realize the misnomer. What you find in SSMS is NOT a full version of RegEx. I'm not sure it even qualifies as a valid...
J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA
September 15, 2022 at 8:16 pm
Viewing 15 posts - 166 through 180 (of 4,085 total)