Take care that the dynamic SQL is highly vulnerable to sql injection attacks. Also, you run it with the EXEC or EXECUTE statement, e.g. EXEC 'dynamic ' + @SQL + ' string'
Cheers,
Rofeu
If you want to use an array-formula and be flexible wrt the base you can use (MOD(COLUMN(<ref>)+<offset>,<ColDif>)=0) instead of ROW(data)=ODD(ROW(data)), where <ColDif> is the number of columns per which you want to check and <offset> the column you want with respect to the base, where <offset>...
true, Loomah.
Feipezi, can you try to declare the variable as a pivotfield?
add this at the top of the code:
Dim pf As PivotField
Shouldn't really make a difference, but worth a shot.
Also, you speak of 'unchecking', this makes me wonder if you're really trying to hide PivotItems instead of...
please ignore the last comment in between brackets. This is obviously flawed.
I was working under the impression that you needed to check if a dog had won a race in the last 3 or 6 races, in which case the min is what you need. I understand now that the dog has to have won ALL of the previous 3...
Hi,
you're right about the order by clause, but not the max. You want to know if there is an instance where the dog has come in at place 1, right? The COUNT seems redundant, as if the dog came in at place 1 in a race in less than 3 respectively 6 races, it would come in at place 1 in a race in...
Sorry, forgot to amend some references:
select R.*
, case
(select min(R1.Finish)
from (select top 1 R2.Finish from RaceResults R2
where R2.RaceId < R.RaceId and R2.Dog = R.Dog)R1)
when 1 then 'YES'...
hmmm, missed that part. How about this:
select R.*
, case
(select min(R1.Finish)
from (select top 1 R2.Finish from RaceResults R2
where R1.RaceId < R.RaceId and R1.Dog = R.Dog)R1)
when 1 then 'YES'...
In office 2003 the ISODD formula is non-standard and is not suited for use in an array-formula. In 2007 I believe it has been made part of the standard and can be used in array-formulae.
Cheers,
Rofeu
No need for testing the value. You can calculate it directly.
select dateadd(d,-(datepart(dw,getdate()-(7-@@datefirst))+6),getdate()) [StartDate]
, dateadd(d,-(datepart(dw,getdate()-(7-@@datefirst)) ),getdate()) [EndDate]
Cheers,
Rofeu
No apologies necessary, George. My understanding of the lifetime of these settings was flawed.
(doesn't take away that the OP can use them for his problem)
Cheers,
Rofeu
That reminds me, you can use @@DATEFIRST to determine which day your instance uses as the starting day of the week, or use SET DATEFIRST to modify it as you wish. (take care that this changes the setting for the sqlserver, not just for your query!)
Cheers,
Rofeu
Hi,
there seems to be a logical inconsistency in your example.
Does Winnerlast3 mean: Did the dog win the last 3 races? OR
Did the dog win one of the last three races?
In case 1 the last record is incorrect in case 2 records 2 and 3 are incorrect. Please clarify.
In case 2 you could use...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.