April 15, 2014 at 8:26 am
jbalbo (4/15/2014)
Thanks for the info..Sorry Im not in here all the time and although I'm sure its not tough just not sure how to create the ddl
You can read all about how to build it by following the first link in my signature, or the first link in Lynn's signature. The big advantage to you is that by posting ddl and sample data in a consumable format you will get tested, accurate and fast code.
Did the last guess at code I post help?
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
April 15, 2014 at 10:39 am
it did.. thank you
But it gave me all the OIDS for the client and not just the most recent
Thanks Again
April 15, 2014 at 11:14 am
As Sean said, if you post the DDL (CREATE TABLE statement) for the table(s) involved, some sample data (a series of INSERT INTO statements (some people here still use SQL Server 2005)) for the tables involved, and the expected results based on the sample data provided you will get better answers to your questions plus the bonus of tested code.
If you don't know how to do this then please read the article that Sean also told you about. You can get to it using the first link in my signature block. It will show you what you need to post and how to do it.
Anything less, then you are just going to get shots in the dark that may or may not help you.
April 15, 2014 at 12:12 pm
Here is my last shot in the dark. This may or may not produce the results you are looking for.
with MySortedRows as
(
SELECT
rsh.Client_ID,
rs.STARTTIME,
rs.OID,
ROW_NUMBER() over (Partition by rsh.ClientID order by rs.StartTime desc) as RowNum
FROM RECORDED_SERVICE rs
INNER JOIN Recorded_Service_Helper rsh ON rs.OID = rsh.Recorded_Service_OID
where rs.STARTTIME < DATEADD(dd, DATEDIFF(dd, 0, GETDATE()), -80)
)
select *
from MySortedRows
where RowNum = 1
ORDER BY Client_ID
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
April 15, 2014 at 3:08 pm
Hi Sean
Thanks for the info, it does what I need, but I HATE the idea that I don't know how to do it
I guess I have a bit of reading....
Thanks Again
Viewing 5 posts - 16 through 19 (of 19 total)
You must be logged in to reply to this topic. Login to reply