Viewing 15 posts - 2,251 through 2,265 (of 10,143 total)
serviceaellis (8/18/2015)
The worksheet is the result that needs to be produced with the highlighted row.
in the Access file the two tables are:
1. PersonMembership - with all the membership...
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
August 19, 2015 at 1:27 am
maxlezious (8/18/2015)
Thank you so much for the updated query Chris. That's is exactly what I was after, really appreciate your time and help with the query.
You're welcome. Sample data, a...
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
August 19, 2015 at 1:25 am
Sure - try this:
SELECT
h.[hours],
a.ActType,
Activities = COUNT(a.ActType),
Points = COUNT(*) * x.points
FROM #tblActivities a
CROSS APPLY (
SELECT
[hours] = CASE
WHEN a.ActType = 'Motion' THEN DATEPART(HOUR, a.isoTimeStamp)
WHEN a.ActType =...
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
August 18, 2015 at 10:28 am
Here's a halfway point:
SELECT
a.*,
x.[hours],
Points = COUNT(*) OVER(PARTITION BY a.ActType, x.[hours]) * x.points
FROM #tblActivities a
CROSS APPLY (
SELECT
[hours] = CASE
WHEN a.ActType = 'Motion' THEN DATEPART(HOUR, a.isoTimeStamp)
WHEN...
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
August 18, 2015 at 8:58 am
Excellent job on putting together sample data. Can you post up what you expect your output to look like? Cheers.
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
August 18, 2015 at 8:42 am
serviceaellis (8/18/2015)
It should show 2015 AND a null row like ClubNo 8004
So neither solutions are showing ClubNo 5305 null row like ClubNo 8004.
Only...
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
August 18, 2015 at 8:31 am
serviceaellis (8/18/2015)
however ...
ChrisM@Work,
yours is showing 2014.
and both are not showing ClubNo 5305 with a null membership info like ClubNo 8004.
NOTE: 5305 has memberships in 2015 and prior...
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
August 18, 2015 at 8:10 am
djj (8/18/2015)
Ed Wagner (8/17/2015)
Luis Cazares (8/17/2015)
whereisSQL? (8/17/2015)
Eirikur Eiriksson (8/17/2015)
Ed Wagner (8/17/2015)
eccentricDBA (8/17/2015)
whereisSQL? (8/17/2015)
DonlSimpson (8/17/2015)
OptimizerCost-based
low-cost provider strategy
Low Quality
WYPIWYG
Consultant
Contractor
Temp
Intern
Affairs
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
August 18, 2015 at 7:58 am
What datatype is te.TripEndTime?
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
August 18, 2015 at 7:01 am
Try this:
SELECT
TE.JobID,
TotalDistanceTravelled as Distance,-- what table is this from?
TotalTripFare AS TotalFare -- what table is this from?
FROM [sqlcdscluster\sqlcds].cdsbusiness.dbo.Tbljobbooking MW
INNER remote JOIN dbo.tbltripenddetail TE
ON MW.JobID = TE.jobID
AND...
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
August 18, 2015 at 6:59 am
born2achieve (8/18/2015)
Hi Chris,Sorry, Am not sure whats wrong in the test data. Please help me on understanding what wrong in test data.
Hi Eirik,
Thanks for your sample.
You say "@Process table data,...
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
August 18, 2015 at 6:08 am
born2achieve (8/18/2015)
Hi Chris,Thanks for your reply and @Process and at @steps are two tables.
select ProcessName,S.Stepname as parent,S.stepname as child from @Process P join @steps S.......any suggestions and sample please
In...
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
August 18, 2015 at 5:56 am
born2achieve (8/18/2015)
Sample data to play with,
declare @Process table(ProcessId int identity(1,1) primary key,ProcessName varchar(100),ParentStep int, ChildStep int);
Insert into @Process(ProcessName,ParentStep,ChildStep)
select 'Process1',1,2 union all
select 'Process2',1,3 union all
select 'Process3',1,6 union all
select 'Process4',4,2 union all
select...
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
August 18, 2015 at 5:39 am
-- This has become more or less the gold standard method
-- for avoiding the division by zero error:
SELECT
i.CPSP35,
i.VINT35,
ISNULL(i.CPSP35 / NULLIF(i.VINT35,0),0) AS High
FROM dbo.SSCCWorderExtract e
INNER JOIN DEV.dbo.INP35 i
ON...
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
August 18, 2015 at 2:02 am
-- Note the use of aliases to reduce noise and make your query more clear
-- avoid right joins, most humans can't read them
-- don't put a column from an outer-joined...
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
August 18, 2015 at 1:56 am
Viewing 15 posts - 2,251 through 2,265 (of 10,143 total)