Viewing 15 posts - 736 through 750 (of 3,543 total)
If your table contained
col1 col2 col3
test1 10 OK
test1 6 DEL
test2 5 OK
the logic would produce
col1 col2 col3
test1 10 OK
test1 -6 DEL
test2 5 OK
and when summed
col1 col2
test1 4
test2 5
May 7, 2014 at 9:54 am
Well subject to indexes and performance testing I do this
;with cte (ID) AS (
SELECT ID
FROM Test1 T1
WHERE @p_flag = 1
ANDT1.moveFlag = 26
UNION ALL
SELECT ID
FROM Test1 T1
WHERE @p_flag = 0
ANDT1.moveFlag <>...
May 7, 2014 at 9:47 am
You are summing values so if there is a mix of DEL and non DEL rows (positive and negative values) then it is possible to have a positive value as...
May 7, 2014 at 9:20 am
Use
=SUM(IIF(Fields!col3.Value = "DEL",-CDec(Fields!col2.Value),CDec(Fields!col2.Value)))
or
=SUM(IIF(Fields!col3.Value = "DEL",CDec(Fields!col2.Value)*-1,CDec(Fields!col2.Value)))
I think putting -1 in brackets may be interpreted as a Boolean false
May 7, 2014 at 7:29 am
Jack Corbett (5/7/2014)
Hehe, I only tested the first one you posted as a quick verification of what mine was doing.
Well the first one works as well 😛
:hehe:
May 7, 2014 at 7:16 am
Jack Corbett (5/6/2014)
Neither my nor David's code does exactly what you are looking for.
Not that I would normally disagree with a master 🙂 but my second query produces...
May 7, 2014 at 6:39 am
ChrisM@Work (5/7/2014)
DROP TABLE #Sample;
CREATE TABLE #Sample (a INT, b INT, c INT);
INSERT INTO #Sample (a, b, c)
SELECT * FROM (VALUES (12345, 10000, 1),
(12345, 10000, 2),
(12345, 10000, 3),
(12345, 10001,...
May 7, 2014 at 6:07 am
Or
;WITH cte ([Order#],ReceiptDate,MaxDate) AS (
SELECT [Order#],ReceiptDate,
MAX(ReceiptDate) OVER (PARTITION BY [Order#])
FROM )
SELECT [Order#],ReceiptDate
FROM cte
WHERE ReceiptDate >= DATEADD(month,-6,MaxDate)
May 6, 2014 at 10:35 am
;WITH cte ([Order#],ReceiptDate) AS (
SELECT [Order#],MAX(ReceiptDate)
FROM GROUP BY [Order#])
SELECT t.Order#,t.ReceiptDate
FROM cte
JOIN t ON t.[Order#] = cte.[Order#]
AND t.ReceiptDate >= DATEADD(month,-6,cte.ReceiptDate)
May 6, 2014 at 10:29 am
Or variation on Chris'
;WITH d (A,B,C,MAXB,MAXC) AS (
SELECT A,B,C,
MAX(B) OVER(PARTITION BY A),
MAX(C) OVER(PARTITION BY A,B)
FROM )
SELECT A,B,C
FROM d
WHERE B = MAXB
AND C = MAXC
*Edited* To fix
May 6, 2014 at 10:00 am
;WITH d (A, B, RowNo) AS (
SELECT A, B, ROW_NUMBER() OVER(PARTITION BY A ORDER BY B DESC)
FROM )
SELECT t.A, t.B, MAX(t.C) AS [C]
FROM d
JOIN t ON t.A = d.A...
May 6, 2014 at 9:52 am
Whether you are Domain Admin or Local Admin does not matter, it is role membership in SSRS that matters ie member of System Administrator role.
BUILTIN\Administrators is added to the System...
May 6, 2014 at 7:33 am
Koen Verbeeck (5/6/2014)
Your question is not really clear. Can you post the table DDL, sample data and desired output?
+1
The only thing I can deduce is this
;WITH cte (B)
AS (SELECT...
May 6, 2014 at 4:11 am
ChrisM@Work (5/2/2014)
... might perform better against your data.
Not sure about that, my query took 3 secs with 80K rows on my test server.
May 2, 2014 at 10:09 am
Non Quirky Update solution (uses Tally table)
;WITH d (RowNo,PirateID,StartEvent,EndEvent,Duration) AS (
SELECT ROW_NUMBER() OVER (PARTITION BY PirateID ORDER BY StartEvent),
PirateID,StartEvent,EndEvent,DATEDIFF(second,StartEvent,EndEvent)
FROM timeSpent
),
r (RowNo,PirateID,N) AS (
SELECT d.RowNo,d.PirateID,t.N
FROM d
JOIN dbo.Tally t ON t.N BETWEEN...
May 2, 2014 at 8:09 am
Viewing 15 posts - 736 through 750 (of 3,543 total)