如何在Access 2007中编写此查询

时间:2016-10-05 10:48:06

标签: c# sql ms-access

select ((select SUM (Total) 
           from Shirt_Mes 
           where CustomerId =2 
           and Created_Date ='2016-10-05 05:25:06.000')
      + (select SUM (Total)
           from Pant_Mes 
            where CustomerId =2 
            and Created_Date ='2016-10-05 05:25:06.000' )

1 个答案:

答案 0 :(得分:1)

MS Access需要带有表的FROM子句。所以,让我们同时转到FROM子句。还有一些其他变化:

select s.sums + p.sump
from (select SUM(Total) as sums
      from Shirt_Mes 
      where CustomerId = 2 and
            Created_Date = #10/5/2016#  -- different date format
     ) as s,  -- Oh, it hurts that MS Access does not have `cross join`
     (select SUM(Total) as sump
      from Pant_Mes 
      where CustomerId = 2 and
            Created_Date = #10/5/2016#
     ) as p;