Viewing 15 posts - 1,336 through 1,350 (of 2,648 total)
I'm not sure what you are trying to do, but COUNT(MyDateField) will count the not null MyDateField values.
Or are you trying to do do something else like COUNT(DISTINCT CONVERT(varchar, MyDateField, 112))...
November 8, 2019 at 1:13 am
Another method:
;WITH CTE AS
(
SELECT t.VisitID,
MAX(t.ActivityDateTime) MaxActivityDateTime
...
November 7, 2019 at 4:02 pm
Here's a simple method to do that:
SELECT year1a.get_customeVal_1-year1b.get_customeVal_2 AS get_customeVal_3,
year2a.get_customeVal_1-year2b.get_customeVal_2 AS get_customeVal_4
FROM (SELECT 1 X) X
CROSS APPLY(SELECT...
November 7, 2019 at 3:46 pm
Have you tried setting the fetchsize to the number of rows you are expecting from the query?
November 7, 2019 at 3:19 pm
You will get better responses if you provide some more test data with your required results.
Also you should make it consumable so in a format like:
DECLARE @Planning_Proposal_Temp...
November 7, 2019 at 2:12 pm
;WITH MyTable AS
(
SELECT * FROM (VALUES
('A', '06/11/2019 09:00', '06/11/2019 09:15'),
('A', '06/11/2019 09:05', '06/11/2019 09:20'),
...
November 6, 2019 at 11:12 pm
Here are two methods:
IF OBJECT_ID('tempdb..#SlowInserts','U') IS NOT NULL BEGIN
DROP TABLE #SlowInserts
END
GO
CREATE TABLE #SlowInserts(Id int IDENTITY(1,1) NOT NULL, Comment varchar(50) NOT NULL)
GO
SET NOCOUNT ON
DECLARE... November 6, 2019 at 10:58 pm
I just took the columns out of the CONCAT from my previous query so they are separate columns, I think this is exactly what you have asked for:
November 5, 2019 at 11:54 am
Hi Jonathan
Thank you very much for your help, which is greatly appreciated.
However, I was probably not so concise in describing what I need. My goal is to produce new...
November 4, 2019 at 5:25 pm
;with cte as
(
select ts.sensor,
ts.temperature,
...
November 2, 2019 at 6:21 pm
SELECT
[LastDayOfThisMonth] = EOMONTH(GETDATE()),
[SecondLastDayOfThisMonth] = DATEADD(DAY,-1,EOMONTH(GETDATE()))
I think EOMONTH was introduced in SQL 2012 and this is the SQL 2008 board.
October 31, 2019 at 2:47 pm
The reason it is ordered is the database engine will need to do a sort to group all the columns in the group by that are equal together. From your...
October 30, 2019 at 11:46 pm
From your description it sounds like you want it to use OR instead of AND:
SELECT *
FROM Cars c
WHERE c.Origin <> 'USA'...
October 30, 2019 at 4:14 pm
I don't know why the query is suddenly taking longer. I just had a quick look at the SQL and saw that bit looked a bit odd. I don't think...
October 30, 2019 at 3:46 pm
select s.c1,s.c2,s.c3, COUNT(*)*IIF(m.c1 IS NULL,0,1) cnt
from stg_tbl s
left join main_tbl m
on m.c1=s.c1
...
October 29, 2019 at 5:55 pm
Viewing 15 posts - 1,336 through 1,350 (of 2,648 total)