Viewing 15 posts - 466 through 480 (of 3,480 total)
Something like this?
--return the previous record where type is F as well.
SELECT tl1.ID, tl1.[type] as ClientType, tl1.ClientName, tl1.completedOn, tl1.CustName, tl1.CustID, tl1.PreviouslyCompletedID,
prev.id, prev.clienttype, prev.clientname, prev.CompletedOn
FROM #temp_Lookback tl1
CROSS APPLY...
November 2, 2021 at 4:26 am
Use LAG() to look at a previous record
October 29, 2021 at 8:58 pm
Upgrade and use STRING_AGG?
use tempdb;
go
create table #PartsFeature
(
PartId int,
Featurekey nvarchar(200),
FeatureValue nvarchar(200),
);
go
insert into #PartsFeature(PartId,Featurekey,FeatureValue)
values
(1550,'Botato','Yellow'),
(1550,'Mango','Red'),
(1550,'dates','Black'),
(1600,'Rice','white'),
(1600,'macrona','Red'),
(1600,'chicken','Yellow'),
...
October 28, 2021 at 2:56 am
Calculate week numbers for each sale record, then you can do something like
SELECT WeekNo = t.N, ProductID, ca.Total_Sales, ca.rnk
FROM Tally t
CROSS APPLY (SELECT TOP 10 ProductID,...
October 21, 2021 at 5:53 am
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
Viewing 15 posts - 466 through 480 (of 3,480 total)