Viewing 15 posts - 526 through 540 (of 1,468 total)
You would be much better off storing your values in the DB with the correct data types. Then you can format the values any way you want in the presentation...
July 16, 2019 at 8:52 am
You are counting the total number of unique records.
You need to get a count per unique set of values
SELECT MainHoldingID, OfferingElementID, [Count] = COUNT(*)
FROM...
July 15, 2019 at 12:39 pm
You cold always try TABLESAMPLE
SELECT *
FROM SchemaName.TableName TABLESAMPLE (100000 ROWS)
July 12, 2019 at 7:09 pm
Perhaps this code will point you in the right direction
WeekNum = DATEDIFF(dd, '1753', [YourDate]) /7 *7 -- Always works for week start on Monday
July 12, 2019 at 5:04 pm
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
Viewing 15 posts - 526 through 540 (of 1,468 total)