I have two table called Production and Chart as below.
Production
Name Layer
CDV TSK
CDV USV
M1 OSK
Chart
Name
L1_CDV_TSK
L1_CDV_TSK
L1_M1_OSK
I have to produce output like this:
Name Layer Count
CDV TSK 2
CDV USV 0
M1 OSK 1
// bse L1_CDV_TKK and L1_M1_OSK are in the Charttable.
How could I write a SQL query to achieve this?
This is my attempt, but it cannot see every row in the Prodution table
Select
p.Name, p.layer, Count(*) as test
from
Production p, Chart c
where
c.chartname like '%'+ p.name+'_'+p.layer + '%'
group by
p.Name, p.layer
Please advise. Thanks a lot!