Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
rsmohankumar
Starting Member
11 Posts |
Posted - 2015-01-06 : 23:30:44
|
Hi,I have data as below, I want the indicator to be displayed by using timestampsId task_id tsk_complete_ts task_due_date Id_end_ts tsk_indicator id_indicator50 2001 01-01-2015 02-01-2015 10-01-2015 GREEN 50 2002 03-01-2015 04-01-2015 10-01-2015 AMBER50 2003 07-01-2015 06-01-2015 10-01-2015 RED50 2004 NULL 09-01-2015 10-01-2015 GREENI 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 RED2) if any task is in RED or AMBER and id got completed before id_end_ts, the display id_indicator as AMBER3) Else GREENI 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. |
|
pascal_jimi
Posting Yak Master
167 Posts |
Posted - 2015-01-07 : 04:01:05
|
you must results or also data send with dinamicalyywith case when procfor exampleDECLARE @test int, @result char(10)SET @test = 10SET @result = CASE @test WHEN 10 THEN 'OK test' ELSE 'Test is not OK'ENDPRINT @result;SET @result = CASE WHEN @test = 10 THEN 'OK test' ELSE 'Test is not OK'ENDPRINT @resulthttp://sql-az.tr.gg/ |
|
|
|
|
|