Quantcast
Channel: ฟอรัม Getting started with SQL Server
Viewing all articles
Browse latest Browse all 8428

Indicator using timestamp

$
0
0

Hi,

I have data as below, I want the indicator to be displayed by using timestamps

Id          task_id       tsk_complete_ts      task_due_date       Id_end_ts    tsk_indicator     id_indicator

50         2001           01-01-2015             02-01-2015            10-01-2015     GREEN         

50         2002           03-01-2015             04-01-2015            10-01-2015     AMBER

50         2003           07-01-2015             06-01-2015            10-01-2015    RED

50         2004           NULL                        09-01-2015            10-01-2015    GREEN

I need to calculate the indicator for the whole id considering all the tasks by using the below conditions,

1) if  tsk_complete_ts > id_end_ts, display id_indicator as RED

2) if any task is in RED or AMBER and id got completed before id_end_ts, the display id_indicator as AMBER

3) Else GREEN

I want the id_indicator to be populate dynamically in view without using stored procedure, id_indicator should be common for whole id.

Task indicator also getting populated in the view using the case statement.

Can you let me know if you have any idea to implement the logic.

Thanks in advance.


Viewing all articles
Browse latest Browse all 8428

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>