Viewing 15 posts - 751 through 765 (of 3,489 total)
Like this?
use tempdb;
go
CREATE TABLE SomeData (
VendorID INT NOT NULL,
PartID INT NOT NULL,
PODate DATE NOT NULL);
GO
INSERT INTO SomeData VALUES(101,10,'1/1/2020'),(201,10,'2/10/2020');
-- setup is done, now answer the question...
SELECT *
FROM (
SELECT...
March 31, 2020 at 9:27 pm
NVARCHAR() fields are text.
March 31, 2020 at 8:07 pm
How about...
"I have this table...
CREATE TABLE SomeData (…);
which contains data like this...
INSERT INTO SomeData(f1,f2,f3...) VALUES (1, 2,3),(2,3,4)…;"
and maybe when I run this query <paste statement here>, I get this result...
March 31, 2020 at 7:43 pm
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
Viewing 15 posts - 751 through 765 (of 3,489 total)