Correct my query

Dear Experts,

I have discomfort with my select query ( pls find it below) I know it is wrong..
I highly appreciate if you could correct it.. thanks in advance
select account_no, case 
when [del_no]=0 to 8 then ( select [days_0_8] from table2)
when [del_no]=9 to 15 then ( select [days_9_15] from table2)

end as 'del'
into table3 from table1

Open in new window

Who is Participating?
Would this work for you?

    WHEN a.del_no BETWEEN 0 AND 8 THEN b.[days_0_8]
    WHEN a.del_no BETWEEN 0 AND 15 THEN b.[days_9_15]
  END as [del]
INTO table3
FROM      table1 a, table2 b
dwe761Software EngineerCommented:
I think we'll need a little more info about the relation between table1 and table2, because if you select all rows of column [days_0_8] every time table1.[del_no] is between 0 to 8, you'll end up with lots of duplication.

Maybe an example of data going in would be helpful and the outcome you'd expect.
parpaaAuthor Commented:
thnks for soln .. It resolved.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.