Viewing 15 posts - 3,196 through 3,210 (of 4,087 total)
Here is how I would approach this.
WITH CTE AS (
SELECT DateValue, [Value], ROW_NUMBER() OVER( PARTITION BY DateValue, [Value] ORDER BY (SELECT 1) ) AS rn
FROM #tableOne
EXCEPT
SELECT DateValue, [Value], ROW_NUMBER() OVER(...
April 24, 2012 at 12:59 pm
I agree with Lynn here. If you can't represent your problem with 50 or fewer records, then your problem is probably too complex to solve in a forum post.
Also,...
April 24, 2012 at 12:40 pm
SSMS is a UI built to work with T-SQL. It is not part of T-SQL. Text mode and grid mode are functions of the UI itself, not native...
April 24, 2012 at 8:21 am
CHARINDEX() has an option parameter (start_location) that can be used to skip the first occurence of the specified string. If you want an example, you'll have to provide more...
April 23, 2012 at 12:39 pm
Please don't hijack old threads. If you have a new question, start a new thread.
Drew
April 20, 2012 at 6:32 pm
polkadot (4/20/2012)
April 20, 2012 at 6:29 pm
polkadot (4/20/2012)
Dwains does pretty much exactly what needs to be done even with the additional business rules, with the exception that it errors in two places:
The problem with Dwain's code...
April 20, 2012 at 3:54 pm
polkadot (4/20/2012)
please explain how 'Days' is introduced. Since you and Dwain are both using DATEDIFF to extract
day portion of the datetime, I would have expected your CASE statements...
April 20, 2012 at 3:44 pm
There is a third option. Update the rows in Table2 so that the constraint will still be valid after the delete. You can either update that column to...
April 20, 2012 at 11:46 am
April 20, 2012 at 9:46 am
polkadot (4/20/2012)
April 20, 2012 at 9:31 am
abs1337 (4/20/2012)
and I get this error "The select list for the INSERT statement contains fewer items than the insert list. The number of...
April 20, 2012 at 8:39 am
Sorry about the error in my code. I forgot to copy the entire code.
Here is an update with changes to provide an average rather than a count. The...
April 20, 2012 at 7:27 am
You're looking for the HAVING clause.
SELECT SerialNum, MAX(UsedDate) AS LastUsedDate
FROM YourTable
GROUP BY SerialNum
HAVING MAX(UsedDate) < DATEADD(YEAR, -1, GETDATE())
Drew
April 19, 2012 at 2:25 pm
dwain.c (4/18/2012)
,ROW_NUMBER() OVER (PARTITION BY Case_ID, PPL_Area, Review_Status
ORDER BY Case_ID, PPL_Area, Review_Status, Revision DESC) As rk
I only quoted the relevant section of the code.
By definition, the partitioning fields are...
April 19, 2012 at 2:03 pm
Viewing 15 posts - 3,196 through 3,210 (of 4,087 total)