Viewing 15 posts - 2,041 through 2,055 (of 4,086 total)
Brandie Tarvin (1/4/2017)
I like CASE personally because it allows me to alter values being returned (or add new information) where as COALESCE just returns the original value.
But you can manipulate...
J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA
January 4, 2017 at 10:45 am
komal145 (1/4/2017)
If firstname is null thne firstname1 , if firstname1 is also null then Firstname2 ...will the case will work ?
Case...
J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA
January 4, 2017 at 10:31 am
Both THROW and RAISERROR cause side effects and user-defined functions cannot cause side effects, so you cannot use a THROW or RAISERROR in a UDF.
Drew
J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA
January 3, 2017 at 3:16 pm
Alan.B (1/3/2017)
drew.allen (1/3/2017)
Alan.B (1/3/2017)
J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA
January 3, 2017 at 2:25 pm
Luis Cazares (1/3/2017)
SELECT name = concat(First_Name, ' ', Last_Name),
Sports = STUFF(iif(Football = 'Y', '; Football','') + iif(Soccer = 'Y', '; Soccer','') + etc, 1, 2, '')
FROM...
J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA
January 3, 2017 at 2:00 pm
Alan.B (1/3/2017)
J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA
January 3, 2017 at 1:16 pm
I prefer the XML concatenation technique. I also put a leading delimiter instead of a trailing delimiter, because you always know exactly where to find the one to remove...
J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA
January 3, 2017 at 1:08 pm
TheSQLGuru (1/3/2017)
With your requirements amendment I think Drew's modification to my query should get you what you want.
Actually, it was a modification of my original query. I didn't realize...
J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA
January 3, 2017 at 10:49 am
TheSQLGuru (1/3/2017)
TheSQLGuru (1/3/2017)
It would be helpful to have sample data and expected output. But I am thinking something like this:select year(awarddate), employeeid, min(awarddate)
from sometable
where awardflag = 1
group by awarddate, employeeid
I...
J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA
January 3, 2017 at 9:40 am
jon.wilson (1/3/2017)
Year Number of First Time Award recipients
2012 40
2013 ...
J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA
January 3, 2017 at 9:35 am
It sounds like you want something like the following.
SELECT employee_id
FROM awards
GROUP BY employee_id
HAVING YEAR(MIN(award_dt)) = YEAR(GETDATE())
Drew
J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA
January 3, 2017 at 8:31 am
Unless you are okay with dirty reads, e.g., skipped records or repeated records, NOWHERE. WITH (NOLOCK) is not a magic "go faster" hint. It comes at a cost,...
J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA
December 30, 2016 at 9:32 am
This is just a gaps and islands problem.
;
WITH Postcode_groups AS (
SELECT Postcode, Rating, ROW_NUMBER() OVER(ORDER BY Postcode) - ROW_NUMBER() OVER(PARTITION BY Rating ORDER BY Postcode) AS Grp
FROM #SamplePostcodes
--ORDER BY Postcode;
)
SELECT...
J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA
December 30, 2016 at 8:56 am
gward 98556 (2/27/2014)
J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA
December 30, 2016 at 8:31 am
watto84 (12/29/2016)
As you suggested, it just needed a slight modification to "order by" in the below section of the code:
ROW_NUMBER() OVER (PARTITION BY Game, Team ORDER...
J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA
December 30, 2016 at 8:11 am
Viewing 15 posts - 2,041 through 2,055 (of 4,086 total)