计数2个表+字符串

时间:2014-07-10 10:35:58

标签: mysql sql

我想在两个不同的表上计算两列,名称相同。一列包含行example: AB0000,第二列(从第二个表)包含行:B0000。我需要将 A 放在第二列的所有行中。我在这里做错了什么?

SELECT [Column_A] 
from
 Table_A  
where
(
Select Count([Column_A]) from Table_A a
where [TIME_DATE_From_Column_A] BETWEEN '2014-06-30 00:00:00' and '2014-07-07 00:00:00'
) 
(
SELECT  'A'+[Column_B] 
from Table_B  b
) 

先谢谢。

1 个答案:

答案 0 :(得分:0)

这是你在找什么?

select column_a, count(*) as a,
       (select count(*)
        from table_b b
        where b.column_a = 'A' + column_b
       ) b
from Table_A  a
where [TIME_DATE_From_Column_A] between '2014-06-30 00:00:00' and '2014-07-07 00:00:00'
group by column_a;