Viewing 15 posts - 196 through 210 (of 476 total)
ChrisM@Work (1/21/2014)
Couple of small changes to MickeyT's otherwise excellent function:
Thanks Chris, I missed that I had messed up the result. I made some changes for performance to what I...
January 21, 2014 at 11:03 am
A slight variation to Luis's method and implemented as an inline table valued function
CREATE FUNCTION compressDuplicates(@code nvarchar(4000))
RETURNS TABLE WITH SCHEMABINDING AS
RETURN
WITH cteTally as (
SELECT TOP(LEN(@code) - 1) ROW_NUMBER() OVER (ORDER...
January 20, 2014 at 7:37 pm
Another option that is very similar to Seans
select customer, sum(PA) AS [Sum_SalesofProductA], sum(PB) AS [Sum_SalesofProductB], sum(PC) AS [Sum_SalesofProductC]
from (
select customer, SalesofProductA PA, null PB, null PC
...
December 17, 2013 at 5:39 pm
twin.devil (12/10/2013)
2ndly if you want to check if there is any value in...
December 11, 2013 at 12:04 am
Hi
Can I put this one up 🙂
select personid, goaldate, goalstatus,
row_number() over (partition by personid, goalstatus, g order by goaldate) * GoalStatus ConsecutiveGoals
from (
select personid, goaldate, goalstatus,
row_number() over (partition by...
November 27, 2013 at 6:02 pm
Hi
I think this will do what you want. Inspired by Dwain's article on Alternative unpivot method[/url]
SELECT s.SaleId, t.TaxCode, SUM(t.TaxValue), SUM(s.Price)
FROM SalesRows s
CROSS APPLY (VALUES (TaxCode, TaxValue), (ExtraTaxCode, ExtraTaxValue))...
November 27, 2013 at 12:34 pm
This is much the same as the the substring option, but uses stuff
SELECT
STUFF(
STUFF(
@TableName
,1
,CHARINDEX('_',@TableName),''
) -- Remove up to first
,CHARINDEX('_',@Tablename) - 1
,9999
,''
) --Remove from second
November 26, 2013 at 11:36 am
dwain.c (11/20/2013)
That's still pretty cool even though mine wasn't the swiftest. 🙂
What I was a bit unsure about was this:
WHERE C IN (3,4) AND b.CellID <> 0;
And whether it should...
November 20, 2013 at 8:02 pm
dwain.c (11/20/2013)
I have one question though, for the 4D case. Are both queries returning the same row counts?
I was a little unsure about what I did...
November 20, 2013 at 7:34 pm
I thought I'd do a performance test of mine and Dwain's on a larger test set (1,000,000 cells).
Basically the results show that while mine is quicker, Dwain's (once reusable Dynamic...
November 20, 2013 at 6:35 pm
dwain.c (11/18/2013)
Laurence Neville (11/18/2013)
I have to award the prize to mickeyT's solution - it is the fastest of all the contributions.
Thanks everyone...
November 18, 2013 at 6:21 pm
OK , so I think I have got there, but it has made my query real ugly
declare @cellid int = 1;
select axiscode, cellid
from (
select c.cellid,
case when c.cellid =...
November 15, 2013 at 1:34 pm
Laurence Neville (11/14/2013)
+----------+---------+
| AxisCode | CellID |
+----------+---------+
| X | 1 |
| X | 2 |
| Y | 1...
November 14, 2013 at 11:13 pm
I'm not sure if I am understanding the requirements for this correctly, but would this work?
declare @cellid int = 1;
select *
from CellAxes c
inner join (
select cellid
from (select axiscode, positiononaxis from...
November 14, 2013 at 5:50 pm
Viewing 15 posts - 196 through 210 (of 476 total)