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 |
rds207
Posting Yak Master
198 Posts |
Posted - 2010-02-04 : 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_RANK1 0 - 5 min 12 5 - 15 min 23 15 - 30 min 34 30 - 1 hr 45 1 - 2 hrs 56 2 - 5 hrs 67 5 - 10 hrs 78 10 hrs - 20 hrs 89 20 hrs - 40 hrs 910 40+ hrs 10My 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_TIME8 10 hrs - 20 hrs 811 2009-11-05 06:34:09.0008 10 hrs - 20 hrs 704 2009-11-05 09:48:05.0008 10 hrs - 20 hrs 772 2009-11-05 09:51:27.0004 30 - 1 hr 57 2009-11-04 02:10:22.0007 5 - 10 hrs 340 2009-11-02 10:10:58.0007 5 - 10 hrs 439 2009-11-04 04:37:06.000-Thanks in Advance |
|
EugeneLim11
Posting Yak Master
167 Posts |
Posted - 2010-02-05 : 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
2937 Posts |
Posted - 2010-02-05 : 03:02:59
|
Why do you need the case statement?PBUH |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-02-05 : 08:51:02
|
I'm sure OP is not giving us full picture. There are values in output coming from columns which he has not included in sample data. Can I ask you to give full sample data in below formathttp://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx |
|
|
rds207
Posting Yak Master
198 Posts |
Posted - 2010-02-05 : 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
22859 Posts |
Posted - 2010-02-06 : 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]" |
|
|
|
|
|
|
|