mardi 6 octobre 2015

Bring through a newly created calculated column in another query

I have 2 separate queries below which run correctly.Now I've created a calculated column to provide a count of working days by YMs and would like to bring this through to query1(the join would be query1.Period = query2.Yms) please see the query and outputs below.

SELECT        Client, ClientGroup, Type, Value, Period, PeriodName, PeriodNumber, ClientName
FROM            metrics.dbo.vw_KPI_001_Invoice 



select YMs,sum(case when IsWorkDay = 'X' then 1 else 0 end) from IESAONLINE.Dbo.DS_Dates
where Year > '2013'
group by YMs 

Query 1
Client  ClientGroup Type    Value   Period  PeriodName        PeriodNumber   ClientName
0LG0    KarroFoods  Stock   5691.68 201506  Week 06 2015    35  Karro Foods Scunthorpe

Query 2
YMs (No column name)
201401  23

Aucun commentaire:

Enregistrer un commentaire