Viewing 15 posts - 9,451 through 9,465 (of 10,143 total)
Like this...
SELECT
SUM(Amount) AS Amount_1 ,
SUM(CASE WHEN Column_1 = 2 AND Column_2 = 4 THEN Amount ELSE 0 END) AS Amount_2
FROM xyz
WHERE Column_1 = 2
AND Column_2 = 4
AND Column_3 =...
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
October 17, 2008 at 7:05 am
Karthick,
1. what are you planning to do once you've found a null and stopped "the process"?
2. what is the process for? Is it for finding nulls?
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
October 17, 2008 at 6:18 am
This is almost certainly easier to test, and quite possibly quicker, if you expand it out into an onion select:
[font="Courier New"]SELECT LagDays, CASE
WHEN LagDays BETWEEN 0 AND 3...
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
October 17, 2008 at 6:14 am
Using ISNULL?
[font="Courier New"]SELECT m.MonitoredEntityCode,
CASE WHEN m.MonitoredLocationCode = 'EMISSION_POINT_1' THEN m.NumericResult END AS 'EMISSION_POINT_1',
CASE WHEN m.MonitoredLocationCode = 'EMISSION_POINT_2' THEN m.NumericResult END AS 'EMISSION_POINT_2',
CASE WHEN m.MonitoredLocationCode = 'EMISSION_POINT_3'...
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
October 17, 2008 at 3:37 am
Did some work for a mailing shop some years ago, we used a method like this for the same thing:
[font="Courier New"]DROP TABLE #Test
CREATE TABLE #Test (RECID INT, COL1 CHAR(1), COL2...
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
October 15, 2008 at 8:54 am
Madhivanan (10/15/2008)
Chris Morris (10/15/2008)
If you create the temp table before executing the string, then (as Barry's code shows) the table...
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
October 15, 2008 at 5:23 am
You're welcome, barcode, many thanks for the feedback.
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
October 15, 2008 at 4:24 am
Try this, barcode:
[font="Courier New"]SELECT c.CONTAINERID, '*** FULL CONTENT ***', 7, c.CONTAINERORIGINID, 1, c.COMPANYID, c.SUBCOID, 1, c.DEPT, c.LEVELID, 1
FROM CONTAINERS c
LEFT JOIN INDEXDATA i ON i.CONTAINERID = c.CONTAINERID AND i.INDEXFIELD1...
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
October 15, 2008 at 3:54 am
That's interesting, I also assumed it took a new connection.
If you create the temp table before executing the string, then (as Barry's code shows) the table is visible to...
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
October 15, 2008 at 2:59 am
Richard Fryar (10/14/2008)
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
October 15, 2008 at 2:11 am
I use this handy gadget:
http://extras.sqlservercentral.com/prettifier/prettifier.aspx
Cheers
ChrisM
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
October 15, 2008 at 2:08 am
Hi Debbie, as Peso points out, your best bet is a clustered index on person + startdate.
This generates your new column. Personally, I'd normalise that into two columns, but here...
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
October 14, 2008 at 4:53 am
Debbie, how about posting a chunk of sample data?
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
October 14, 2008 at 3:36 am
Debbie Edwards (10/14/2008)
I got the first example to bring back data but I dont understand the results. The 2nd example worked also but...
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
October 14, 2008 at 2:43 am
Hi Debbie
The "running total" update statement - the one with the variables in it - can be a bit quirky. It's best if the data is physically ordered in the...
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
October 14, 2008 at 2:41 am
Viewing 15 posts - 9,451 through 9,465 (of 10,143 total)