| Author |
Topic  |
|
|
rds207
Posting Yak Master
198 Posts |
Posted - 02/04/2010 : 19:14:57
|
Hi
Could any body please help me writing the case statements for the below insert query from the below code table ..
Code Table:
RUNTIME_CODE RUNTIME_CATEGORY CATEGORY_RANK 1 0 - 5 min 1 2 5 - 15 min 2 3 15 - 30 min 3 4 30 - 1 hr 4 5 1 - 2 hrs 5 6 2 - 5 hrs 6 7 5 - 10 hrs 7 8 10 hrs - 20 hrs 8 9 20 hrs - 40 hrs 9 10 40+ hrs 10
My insert Query is below:
Insert INTO DW_T_ASW_JOBDATA( [RUNTIME_CODE], [RUNTIME_MIN] )( SELECT NULL, DATEDIFF(MINUTE,E.EC_START_TIME,E.EC_FINISH_TIME), E.EC_START_TIME, dateadd(HOUR,8,EC_START_TIME) FROM dbo.DW_T_EC_TGT E WHERE EC_STEP_INDEX IS NULL)
Expected Output: RUNTIME_CODE RUNTIME_CATEGORY RUNTIME_MIN START_TIME 8 10 hrs - 20 hrs 811 2009-11-05 06:34:09.000 8 10 hrs - 20 hrs 704 2009-11-05 09:48:05.000 8 10 hrs - 20 hrs 772 2009-11-05 09:51:27.000 4 30 - 1 hr 57 2009-11-04 02:10:22.000 7 5 - 10 hrs 340 2009-11-02 10:10:58.000 7 5 - 10 hrs 439 2009-11-04 04:37:06.000
-Thanks in Advance
|
|
|
EugeneLim11
Posting Yak Master
167 Posts |
Posted - 02/05/2010 : 02:46:31
|
Your Insert statement is very funny. There are two columns to insert into, but I counted 4 columns in your select statement. How do you put 4 columns into 2 columns?
What exactly are you trying to accomplish? |
 |
|
|
Sachin.Nand
Flowing Fount of Yak Knowledge
2937 Posts |
Posted - 02/05/2010 : 03:02:59
|
Why do you need the case statement?
PBUH |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
India
48076 Posts |
|
|
rds207
Posting Yak Master
198 Posts |
Posted - 02/05/2010 : 14:14:31
|
I know i had some wrong statement here but i figured out the solution for this question , Thank you,
how do i close the topic ? |
 |
|
|
Kristen
Test
United Kingdom
22191 Posts |
Posted - 02/06/2010 : 01:56:57
|
| No need to close the topic, but some people (very few actually!!) re-edit their first post and change the Subject to append "[RESOLVED]" |
 |
|
| |
Topic  |
|