Viewing 15 posts - 316 through 330 (of 532 total)
You'll need to index your tables properly or your performance on this will be horrible, but I think this is basically what you're looking for:
select a.id,
a.CustomerNumber,
a.AccessedDate,
a.OperatorName,
nlh.computer_nm,
nlh.login_dt
from action...
June 15, 2010 at 3:50 pm
with cteTest (RowNum, EmpID, LogTime)
as
(
select ROW_NUMBER() OVER(PARTITION BY EmployeeID ORDER BY LogTime ASC),
EmployeeID,
LogTime
from #Test
)
select cc.EmpID,
cc.LogTime
from cteTest cc
left join cteTest cp
on cp.EmpID = cc.EmpID
and cp.RowNum = cc.RowNum - 1
where DATEDIFF(ss, coalesce(cp.LogTime,...
June 15, 2010 at 12:13 pm
This is slightly more efficient:
SELECT DATEADD(hh, DATEDIFF(hh,0,'2010-04-04 14:15:02'), 0)
June 15, 2010 at 11:56 am
loki1049 (6/15/2010)
June 15, 2010 at 11:44 am
scott.pletcher (6/11/2010)
At any rate, what solution did *you* provide? NONE. All...
June 11, 2010 at 12:25 pm
scott.pletcher (6/11/2010)
Yes, I took the short-cut, because as *I* pointed out the code will result in full scan anyway.
When...
June 11, 2010 at 12:21 pm
scott.pletcher (6/11/2010)
posted a very plausible case that broke your code.
Depends. I was answering the request to select only rows with a gap of 2 or less...
June 11, 2010 at 12:12 pm
scott.pletcher (6/11/2010)
lol, you two are funny. I post code that actually works and you keep talking to each other about how "it can't be done". ROFLOL.
I posted a...
June 11, 2010 at 12:03 pm
Jeff Moden (6/10/2010)
June 11, 2010 at 11:00 am
scott.pletcher (6/11/2010)
but otherwise (such as in this case) this will result in a table scan even if there is an index on the DueDate.
You could rephrase the query to...
June 11, 2010 at 10:47 am
Lynn Pettis (6/11/2010)
DECLARE @filterStart DATETIME
DECLARE @filterEnd DATETIME
SET @filterStart = '10/06/2010'
SET @filterEnd = '10/07/2010'
SELECT ...
WHERE
DueDate BETWEEN @filterStart AND @filterEnd
...
June 11, 2010 at 10:36 am
I agree with Lynn, all that is needed to get the exact same records is:
DECLARE @filterEnd DATETIME
SET @filterEnd = '10/07/2010'
SELECT ...
WHERE CASE WHEN DueDate < @filterEnd
scott.pletcher (6/10/2010)
June 10, 2010 at 5:41 pm
This is basically the same as Jason's but it's checking to make sure that the year is the same and the month is literally the next month. So depending...
June 10, 2010 at 4:41 pm
create table #PayPeriod
(
payPeriodint,
periodDescvarchar(50),
startDatedatetime,
endDatedatetime
)
insert into #PayPeriod (payPeriod, periodDesc, startDate, endDate)
select 108, 'Period 12/20 - 01/02', '12/20/2009', '1/2/2010' union
select 109, 'Period 01/03 - 01/16', '1/3/2010', '1/16/2010' union
select 110, 'Period 01/17 - 01/30',...
June 10, 2010 at 3:15 pm
I could be missing something here ... I'll be honest, I didn't read through everything.
But I'm not sure on this where the cte recursion comes into play on this ......
June 10, 2010 at 2:52 pm
Viewing 15 posts - 316 through 330 (of 532 total)