有3个表
table1:  custom_num,custom_name          //custom_num不重复
table2:  custom_num,product_num,prise    //custom_num重复
table3:  custom_num,repair_num,repair_time,repair_prise;//custom_num重复
现在的希望是,查找出所有repair_time在时间一和时间二之间的数据
custom_name,sum(prise),sum(repair_prise),custom_name

解决方案 »

  1.   

    怎么只剩下一句了?补!
    有3个表
    table1:  custom_num,custom_name          //custom_num不重复
    table2:  custom_num,product_name,prise,num
    table3:  custom_num,repair_time,repair_prise
    现在要查找出所有repair_time在time1和time2之间的数据:
    custom_name,sum(prise*num),sum(repair_prise)
    怎样才能实现呢?         
      

  2.   

    select custom_name,s1=sum(prise*num),s2=sum(repair_prise)
    from (table1 inner join table2 on            table1.custom_num=table2.custom_num) inner join table3 on   
    table1.custom_num=table3.custom_num
      

  3.   

    and repair_time between time1 and time2
      

  4.   

    where table3.repair_time between time1 and time2
      

  5.   

    sandsand(小沙沙)  is right