May 24, 2012 at 9:31 am
Does that work for you?
_______________________________________________________________
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/
May 24, 2012 at 9:53 am
Gone through rules...the query is not working as per rules I posted:(
May 24, 2012 at 10:16 am
komal145 (5/24/2012)
Gone through rules...the query is not working as per rules I posted:(
Then you will either need to tweak the query or explain what "not working as per rules" means.
_______________________________________________________________
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/
May 24, 2012 at 1:26 pm
As per your query we are getting recent datetime and if it is enrollment analyst then assigning it as "complete" if not "pending".But I need a query which checks next step that occured after "Current step = Enrollment Analyst" and if there is additional Current_step then Assigning that entry as "Completed" else "Incomplete"
I wrote a cursor to loop through each step in the table and wrote a function to get the next step ( to check if there is any current step after current step = Enrollment analyst).
Thank you for spending your time.Thanks for the Help.
May 24, 2012 at 1:36 pm
You do not need a cursor to do this. Cursors are the bane of t-sql development.
If you can explain what you want for output I can help. Unfortunately so far you not provided what you expect for output. Why don't you hard code the insert statements into your new table. That way I have something to compare with. A clear explanation of the business rules would help too.
By the way, you keep mention next and previous records. SQL tables have no concept of order. I was assuming by next you meant to order them by event_time. Which of course until now I didn't realize this is a varchar column. This should be a datetime column NOT varchar.
_______________________________________________________________
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/
Viewing 5 posts - 16 through 19 (of 19 total)
You must be logged in to reply to this topic. Login to reply