Viewing 15 posts - 496 through 510 (of 3,505 total)
DECLARE @MyDate DATE = '10/9/2021';
SELECT DATEPART(week,@MyDate);
DATEPART(week,[DateColumn]) will return the weeknumber of the year. Just group on that.
Help yourself. Introduce yourself to the help files on SQL Server.
October 9, 2021 at 7:37 am
You'd have to use IIF([Date1]>=[Date2],[Date1],[Date2]) Then maybe do an aggregate on that expression.
October 8, 2021 at 3:18 am
Isn't the total distance covered the sum of all distances up to this pass? If that's the case, then why not use a windowing function and sum(distance)? and then use...
October 6, 2021 at 11:53 pm
Maybe Jeffrey was too subtle...
You really need to read this article:
Forum Etiquette: How to post data/code on a forum to get the best help
I'd post my attempt, but I...
September 23, 2021 at 6:18 am
Depends what the database is doing at the time. Requests get queued until the database can process the request, so sometimes it takes very little time, sometimes it takes more...
September 16, 2021 at 1:55 pm
There's one big thing you are missing from your question - What are you trying to accomplish? Changing the EXISTS clause to a join will cause you to have duplicate...
September 14, 2021 at 12:27 am
You have data. How about posting CREATE TABLE and INSERT scripts so we can see what you're working with? While you're at it, post the expected result... but for the...
September 13, 2021 at 5:19 pm
Something like this? (I may be oversimplifying something...)
-- exclude when phone # refers to multiple people.
-- exclude when phone # refers to multiple people.
SELECT * FROM CustomerPolicies...
September 12, 2021 at 2:13 am
The easiest way is to use a Calendar table and explode the join
-- DROP TABLE #t
CREATE TABLE #t (CustNo int, Net money, StartDt datetime, EndDt datetime)
INSERT INTO...
September 11, 2021 at 2:59 pm
use TOP() or LIMIT and do the delete in batches until @@ROWCOUNT = 0?
September 10, 2021 at 3:31 pm
Post the CREATE TABLE scripts and someone can help you. =)
September 10, 2021 at 2:12 am
Great! Could you post the solution you came up with?
September 9, 2021 at 5:15 pm
I'm no expert, but you have to unravel SQL from the innermost queries to the outermost.
is there a shortcut? Not that I know of. I'd love to be proven wrong,...
September 8, 2021 at 8:13 pm
Your data is a bit wonky, but maybe something along these lines?
SELECT meshtype,
[datetime] as stamp,
tonsProduced,
theDate = CAST([datetime] AS DATE),
theTime = CAST([datetime] AS TIME)
-- fv = first_value([datetime]) OVER (PARTITION BY meshtype...
September 8, 2021 at 8:12 pm
Normalization 101 time, I think. that's a LOT of repeating fields (any time I see a column name with a number at the end, I'm immediately suspect).
Is this supposed to...
September 7, 2021 at 7:18 pm
Viewing 15 posts - 496 through 510 (of 3,505 total)