Viewing 15 posts - 1,126 through 1,140 (of 1,244 total)
To expand on Jeff's (and others) point... It would be helpful if you were to give some explanation as to what constitutes "consecutive" in this case.
Letting us know which of...
June 30, 2015 at 8:23 am
skilly2 (6/29/2015)
This solution worked as well. It works well with a small number of rows, but I don't think is easy as the above solution to adopt to a...
June 29, 2015 at 8:23 pm
sratemo (6/29/2015)
I'm using version 2008. Did not really pay attention to it, and it doesn't come with LAG and LEAD functions. I've just re-posted this on the 2008...
June 29, 2015 at 7:42 pm
pietlinden (6/29/2015)
The...
June 29, 2015 at 2:45 pm
There is always the option of dumping the results of the execution into a temp table and joining to that.
Here's a rather trivial example but it will hopefully illustrate the...
June 29, 2015 at 2:42 pm
Based on your desired output, I think the following is what you're looking for...
WITH AddRN AS (
SELECT
t.ID,
t.Date,
ROW_NUMBER() OVER (PARTITION BY t.ID ORDER BY t.Date) AS RN
FROM
#temp t
)
SELECT
a.ID,
SUM(CASE WHEN DATEDIFF(yy,...
June 29, 2015 at 2:20 pm
DDL & consumable test data is the important thing. Something more akin to the following...
IF OBJECT_ID('tempdb..#temp') IS NOT NULL
DROP TABLE #temp;
CREATE TABLE #temp (
ID INT NOT NULL,
[Date] DATE NOT...
June 29, 2015 at 2:04 pm
Yea... That's simple enough we (you actually) just need to know where that information exists. Once you have that in scope, simply use that to replace the hard coded value.
June 29, 2015 at 10:53 am
So... You want any times that are between midnight and 8:09 to increment to the next day?
If that's correct, the following should work...
SELECT
CASE WHEN mt.MyTime >= '00:00:00' AND mt.MyTime...
June 29, 2015 at 9:21 am
This should get you what you are looking for...
-- test data --
IF OBJECT_ID('tempdb..#PatientProblem') IS NOT NULL
DROP TABLE #PatientProblem;
CREATE TABLE #PatientProblem
(
PatientID INT,
AdmissionDate DATETIME,
DischargeDate DATETIME,
Cost MONEY
)
GO
--Insert Data
INSERT INTO #PatientProblem(PatientID,AdmissionDate,DischargeDate,Cost)
VALUES
(1009,'2014-07-27','2014-07-31',1050.00),
(1009,'2014-08-01','2014-08-23',1070.00),
(1009,'2014-08-31','2014-08-31',1900.00),
(1009,'2014-09-01','2014-09-14',1260.00),
(1009,'2014-12-01','2014-12-31',2090.00),
(1024,'2014-06-07','2014-06-28',1900.00),
(1024,'2014-06-29','2014-07-31',2900.00),
(1024,'2014-08-01','2014-08-02',1800.00);
-- index to eliminate...
June 28, 2015 at 11:07 pm
Looks like there have been some new posts since I started in on my version of the solution... I haven't had a chance to test any of them against what...
June 26, 2015 at 3:23 pm
+1 on this being a VERY BAD design...
If for some reason you aren't able to rework the design, something like the following should work...
DECLARE @search VARCHAR(10);
SET @search = 'dog,COW';
WITH T(C)
AS
(
SELECT...
June 20, 2015 at 9:40 am
Carl Caputo (6/20/2015)
June 20, 2015 at 9:20 am
Are you able you simply put the query in a stored proc and then simply execute the sp over the ODBC connection?
June 19, 2015 at 2:47 pm
Travis Dean (6/19/2015)
This too is giving me duplicates... I don't need every line from the left table - only distinct IDs.
If you check Post #1695927, you'll see that the final...
June 19, 2015 at 7:50 am
Viewing 15 posts - 1,126 through 1,140 (of 1,244 total)