Viewing 15 posts - 526 through 540 (of 1,464 total)
Take a look at the ROW_NUMBER() function
WITH cteData AS (
SELECT *, rn = ROW_NUMBER() OVER (PARTITION BY {Fields to group by} ORDER BY {Fields that...
July 11, 2019 at 4:34 pm
Drew's code can be easily modified to include the extra condition for EventType = 5001. It is still way more efficient than my code
WITH netobjectidgroups AS
(
SELECT *
,CASE...
July 9, 2019 at 6:33 pm
You need to include cs.nxtEventID in the filter for EventType = 5001
DECLARE @netObjectId varchar(50) = '693';
WITH cteStart AS (
SELECT
s.netobjectid
...
July 9, 2019 at 12:12 pm
The query that you got from Jingyang Li over at the MSDN SQL Server forum, can be easily modified to get the correct result by simply adding a...
July 8, 2019 at 7:05 pm
Your posted DDL seems to have different values to your expected outcome values.
That said, I believe that the following code should get you on your way
WITH cteStart...
July 8, 2019 at 5:29 pm
I would start by creating a table of valid time slots
IF OBJECT_ID(N'dbo.Timeslots', N'U') IS NOT NULL
BEGIN
DROP TABLE dbo.Timeslots;
END;
GO
CREATE TABLE dbo.Timeslots (
SlotStart...
July 8, 2019 at 1:18 pm
What are your data types?
What happens when the StartTime and FinishTime cross over midnight?
Are the time durations always in 60 minute segments?
July 8, 2019 at 12:31 pm
You need to use a CTE or a sub-query to generate your aggregates, and then join to that for the update
WITH cteUpdate as (
select Milestone.SCHOOLNUM,...
July 7, 2019 at 6:48 am
Hi All, I have a question, using sql query can I get the current IST time and current PST time ? Thanks, Sam
July 5, 2019 at 1:19 pm
Firstly, your random data generator - Using a recursive CTE to create a list of numbers is very inefficient. Below is a more performant script to create your sample data....
July 5, 2019 at 7:10 am
Thanks for posting the alternate solution, which seems to have a better execution plan than the one that I posted.
July 3, 2019 at 6:04 pm
It's the law of home ownership, Steve... all 10 minutes jobs take at least 6 hours to complete. 😀
Aint that the truth
July 3, 2019 at 5:42 pm
Thanks for posting your issue and hopefully someone will answer soon. This is an automated bump to increase visibility of your question.
I'm sorry, but this amused me...
July 3, 2019 at 3:29 pm
The following code is based on a solution previously provided by Drew Allen
https://www.sqlservercentral.com/Forums/FindPost2025579.aspx
WITH cteStart AS (
SELECT aa.account_id, aa.active_date
...
July 3, 2019 at 3:22 pm
You can use a CASE statement
CREATE VIEW [dbo].[GCDFview]
AS
SELECT p.FirstName, p.LastName, c.city, p.instructorInt as 'Instructor'
, s.stateAbbrveation AS 'State', 'USA' AS Country, 'GCDF' AS Certifications
, p.PeopleID + CASE WHEN...
July 2, 2019 at 8:11 pm
Viewing 15 posts - 526 through 540 (of 1,464 total)