Viewing 15 posts - 1,216 through 1,230 (of 3,957 total)
Another take (also not handling crossing midnight), with some sample data added.
declare @t as table (ptr int identity, START time, ENDD time)
insert into @t (START, ENDD)
SELECT '09:30', '10:30' union all
SELECT...
October 30, 2013 at 6:41 pm
I am neither a health care professional nor particularly healthy, but perhaps I can help. 😛
J M-314995 (6/20/2007)
October 29, 2013 at 11:42 pm
Looks like homework to me.
Start by explaining why you want the first row with the StudentID you've highlighted.
Then look up ROW_NUMBER() in MS Books on Line.
October 29, 2013 at 9:23 pm
Note that SQL 2012 has a new analytical function (LAG) that makes short work of this.
SELECT CSS_Service_Ticket_id
,Opened=MIN(Time_Stamp)
,Closed=MAX(Time_Stamp)
,Duration=SUM(Duration)
FROM
(
SELECT CSS_Service_Ticket_id
...
October 29, 2013 at 9:14 pm
Now that I've had some coffee, I think this is what I meant.
SELECT CSS_Service_Ticket_id
,Time_Stamp, jh.New_Value
INTO #Temp
FROM #rsys_tables_temp ta
INNER JOIN #journal_items_temp ji ON ji.Reference_Table = ta.Tables_Id
INNER JOIN...
October 29, 2013 at 8:37 pm
mickyT (10/29/2013)
dwain.c (10/29/2013)
, rnk=MIN(rnk)
From the SELECT list of the inner query. I was using it for testing. It...
October 29, 2013 at 8:35 pm
BTW. You can probably remove this from the Tally solution:
, rnk=MIN(rnk)
From the SELECT list of the inner query. I was using it for testing. It might drop...
October 29, 2013 at 7:56 pm
mickyT (10/29/2013)
And so far Dwains Tally solution looks like the winner based on the IO stats:-D
So much for my guess. I was betting on #2 and a tie with...
October 29, 2013 at 7:52 pm
A couple more alternate approaches:
-- #1: Using a Tally table
WITH Tally (n) AS
(
SELECT ROW_NUMBER() OVER (ORDER BY (SELECT NULL))
FROM (VALUES (0),(0),(0),(0),(0),(0),(0),(0),(0),(0)) a(n)
)
SELECT...
October 29, 2013 at 7:00 pm
ChrisM@home (10/29/2013)
Thanks Dwain for another informative and well-written article. It wouldn't surprise me if the discussion provoked a significant rewrite with more use cases, based on posts so far.
Thanks Chris....
October 29, 2013 at 6:09 pm
It seems that there is quite a bit more variation than I thought. I have 2 machines available for testing:
1. The Lenovo reported at the end of the article,...
October 29, 2013 at 5:29 am
Koen and sqlnaive - Thank you sirs for the feedback.
Now on to rerunning my test harness with a couple of variations.
October 29, 2013 at 3:33 am
One thing I'd look at is integration points.
If application A is using data from any application sitting on server Y, perhaps its database is best stored on server Y.
October 29, 2013 at 12:28 am
Why not avoid the UPDATE entirely by making [SellThrough1Hour], [SellThrough2Hour], etc. computed columns?
You already have the CASE statements you'd need in those column definitions.
October 28, 2013 at 7:20 pm
Viewing 15 posts - 1,216 through 1,230 (of 3,957 total)