sql server - Join sql table on Datename -


i have select statements looks

 select  count(*) 'total', datename(dw, [callstart]) 'totaldayname'    #totals    [warehouse].[dbo].[voice] (nolock)    select  datename(dw, [callstart]) 'day1'      [warehouse].[dbo].[calls] ref (nolock)   join #totals total on **ref.day1**  = total.totaldayname 

i have simplified query question. need join #totals calls table on totaldayname = ref.day1. know can't use alias join table. have tried totaldayname = ref.datename(dw, [callstart]) gives me error well.

i think you've got syntax wrong, said

i have tried totaldayname = ref.datename(dw, [callstart])

but should have been

totaldayname = datename(dw, ref.[callstart]) 

it should work fine


Comments

Popular posts from this blog

Fail to load namespace Spring Security http://www.springframework.org/security/tags -

sql - MySQL query optimization using coalesce -

unity3d - Unity local avoidance in user created world -