Viewing 15 posts - 3,826 through 3,840 (of 4,085 total)
You need to include a CASE statement in your HAVING clause.
Select @constituency, o.customer_no
, Count(l.per_no) AS AllPerf
, COUNT(CASE p.season WHEN 165 THEN l.perf_no...
J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA
October 15, 2010 at 11:36 am
Michael Valentine Jones (10/15/2010)
selectDaysTillChristmas =
datediff(dd,getdate(),dateadd(yy,datediff(yy,-1,getdate()),-7))
But this will give you negative numbers from Dec. 26-31. Here is the modified code to always give you the NEXT Christmas.
select DateDiff(Day, GetDate(), dateadd(yy,datediff(yy,-1,DateAdd(Day,...
J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA
October 15, 2010 at 11:22 am
Maybe what you really want to do is create a view. That way you can use the trick of specifying the TOP (100) PERCENT, so that you can specify...
J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA
October 15, 2010 at 11:00 am
This is exactly what the PIVOT operator was designed for. Check it out in BOL.
That being said, using a crosstab is often more efficient.
select datepart(ww, created) as Week,
COUNT(CASE s.commonname...
J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA
October 15, 2010 at 10:41 am
I think the best measure is probably
(totalRecords - uniqueRecords)/totalRecords
In your example that would give 75%. The hard part is, of course, identifying the unique records.
Drew
J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA
October 15, 2010 at 10:10 am
I don't see that how often it is executed has any bearing on the issue unless it starts blocking itself. I wouldn't immediately target the FOR XML as being...
J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA
October 14, 2010 at 3:18 pm
Eric1/2aB (10/14/2010)
I am trying to make a case to have this code redesigned in a way that FOR XML is not needed.
Do you have a personal vendetta against the FOR...
J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA
October 14, 2010 at 10:29 am
tyson.price (10/13/2010)
Sorry about the formatting. I must have used the code tags wrong. 🙂
The "/" only goes in the closing tag. You have it in both the opening...
J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA
October 13, 2010 at 8:49 am
ravimodi (10/12/2010)
J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA
October 13, 2010 at 8:36 am
You beat me to it, but I'm posting mine anyhow, because there are some points that I wanted to address.
WITH Charges AS (
SELECT Account, Sum(qty*amount) AS Total_Charges
FROM test_charges AS tc
INNER...
J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA
October 12, 2010 at 3:01 pm
Derrick Smith (10/12/2010)
AND (NOT email IN (SELECT email FROM failures))
AND (NOT email IN (SELECT email FROM removes))
AND (NOT email IN (SELECT email FROM contacts));
I'd be willing...
J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA
October 12, 2010 at 2:29 pm
aniccadhamma (10/12/2010)
J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA
October 12, 2010 at 12:59 pm
PSB (10/11/2010)
The condtition is if the "Name" comes in as NULL then the "ID" should be NULL
Else...
J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA
October 12, 2010 at 10:56 am
You may have duplicates in your SELECT statement. Adding a DISTINCT clause may resolve this.
Drew
J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA
October 12, 2010 at 10:27 am
SSSolice (10/11/2010)
J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA
October 11, 2010 at 3:09 pm
Viewing 15 posts - 3,826 through 3,840 (of 4,085 total)