Viewing 15 posts - 766 through 780 (of 3,501 total)
Use ROW_NUMBER() with PARTITION BY?
How about some sample data and expected results?
March 31, 2020 at 7:39 pm
Is your data really double-byte (from double-byte languages like Arabic and Japanese?) If not, just use VARCHAR instead.
March 31, 2020 at 7:38 pm
Why not do both and compare the query plans?
SET STATISTICS TIME, IO ON;
and then do it. Which one takes longer?
March 30, 2020 at 12:22 pm
Thought I had it...but I'm missing a date (because the LAG/LEAD is cutting it off). Anyway, here's the code:
SELECT *
FROM
(SELECT EmployeeID
, TranDate
, DATEADD(day,-1,LEAD(TranDate,1) OVER (PARTITION BY EmployeeID...
March 25, 2020 at 6:17 am
.. and we can't help you without any data. How about a thin horizontal slice of the table's data. Enough to reproduce the problem. It's really hard to execute a...
March 24, 2020 at 1:32 am
Oh, right! That's what I was missing. The times before 8:30 and after 16:00 don't count. That's where the half hour came from. I didn't chop those off. Explains why...
March 23, 2020 at 4:23 pm
How can you get a non whole number answer if everything starts and ends on the hour? Because each room is effectively for two meetings at once?
March 23, 2020 at 3:35 pm
Andy,
I created the table and added the insert scripts... (although the table really needs indexing!)
If you really need help, help us help you. Read this link: How to post code...
March 23, 2020 at 6:00 am
Like this?
SELECT dbname
, [type]
, CAST( ((SUM(Size)* 8) / 1024.0) AS DECIMAL(18,2) ) AS SizeMB
FROM
(SELECT DB_NAME(database_id) as dbname,
[Type] = CASE WHEN Type_Desc = 'ROWS' THEN 'Data File(s)'
WHEN Type_Desc =...
March 22, 2020 at 8:09 pm
StopType is either (P)ick or (D)rop
(That's why I was doing the CASE WHEN StopType = 'D' THEN -1 ELSE 1 END part... to convert those pickups to positive numbers and...
March 22, 2020 at 3:04 am
So you just want a total number of passengers picked up during the whole route - doesn't matter when they get on or off? then you'd just count the PassengerIDs...
March 22, 2020 at 2:25 am
It's the "who's the conductor of the train?" joke, but you really want the number of passengers on the train at any point.
I wouldn't count the bit column, personally. I'd...
March 22, 2020 at 2:13 am
I guess I answered this question, the one you explicitly asked instead of the one you intended:
I'm trying to get a running total of how many riders are on the...
March 22, 2020 at 12:33 am
Not a clue what Modulo has to do with this. Sounds like you want a running total of riders boarding minus a running total of riders leaving the bus. Maybe...
March 22, 2020 at 12:04 am
Post your SQL statements here... nobody's going to download files from people they don't know.
March 21, 2020 at 8:13 pm
Viewing 15 posts - 766 through 780 (of 3,501 total)