Viewing 15 posts - 2,761 through 2,775 (of 4,086 total)
T-SQL was designed to mirror English, so the order of processing does not match the written order. Queries are processed in the following order:
FROM
WHERE
GROUP BY
HAVING
SELECT
ORDER BY
TOP/OFFSET-FETCH
Each step produces a...
March 29, 2016 at 7:57 am
Lynn Pettis (3/28/2016)
scottcabral (3/28/2016)
works, thanks!It works as long as there aren't two rows of data for the same Download, AccountNum, RootPolicyNum where CurrentStatus = 'Renewed' for both.
I think that can...
March 28, 2016 at 2:59 pm
Hugo Kornelis (3/28/2016)
March 28, 2016 at 12:39 pm
You can always use a CASE expression, but it sounds like you might have a LOT of cases, so a table value constructor might be a better approach. You...
March 28, 2016 at 9:27 am
Hugo Kornelis (3/23/2016)
criterium
Completely off-topic, but criteria is from Greek, so it uses the Greek singular criterion rather than the Latinate singular criterium
Drew
March 23, 2016 at 1:01 pm
I agree that there are cases where the order is important, but my point was that the number of cases is far smaller than most people think. Running aggregates...
March 22, 2016 at 11:12 am
Eirikur Eiriksson (3/21/2016)
kuopaz (3/21/2016)
March 21, 2016 at 10:44 am
lkennedy76 (3/17/2016)
Jeff Moden (3/16/2016)
lkennedy76 (3/16/2016)
Thank everyone for all your replies. I am...
March 17, 2016 at 12:06 pm
You're using temp tables to store results that are only used once(#MinPeriod and #MaxPeriod). It is better to use a CTE or a derived table for single use temporary...
March 17, 2016 at 9:02 am
When posting optimization questions, it really helps to provide the actual execution plan (or at least the estimated execution plan).
That being said, the first thing I see is an overuse...
March 17, 2016 at 8:54 am
Actually, the best approach is to CROSS JOIN your missing Jobs table with your status table and then LEFT JOIN to the job status table. That way you don't...
March 17, 2016 at 8:35 am
This type of formatting is usually best left to the presentation layer, SSRS for example.
The only way to do it in T-SQL is with dynamic SQL.
If you tell us what...
March 17, 2016 at 8:19 am
The range is actually much more flexible than stated. For example these are all valid ranges:
BETWEEN UNBOUNDED PRECEDING AND 1 PRECEDING
BETWEEN 10 PRECEDING AND 5 PRECEDING
BETWEEN 1 FOLLOWING AND...
March 15, 2016 at 4:04 pm
lkennedy76 (3/15/2016)
I took out the ISNULL, the SUM function requires a group by so I grouped it by ID not the amounts, all amounts are now NULL
As Gail already said,...
March 15, 2016 at 11:15 am
This type of request is usually best done in the presentation layer, such as SSRS or even an Excel Pivot Table.
If you insist on doing it in SQL you'll need...
March 11, 2016 at 1:07 pm
Viewing 15 posts - 2,761 through 2,775 (of 4,086 total)