日期:2014-05-19  浏览次数:20589 次

高手快帮帮我
描述如下:
sql   1:
select   substr(b.operdatedate,1,10)   'time '
from   card_sale_note   d,   card_sale_card     b,     card_type   c  
where   (d.id   =   b.id   and     d.if_new_card   =   b.if_new_card
and   b.if_exit_card   is   null   and   b.type_id   =   c.type_id)
and   date(b.operdatedate)> =date( '2006-07-27   00:00:00 ')
and   date(b.operdatedate) <=date( '2007-07-27   23:59:59 ')
group   by   substr(b.operdatedate,1,10)     order   by     substr(b.operdatedate,1,10)   asc
返回为
      time
2007-07-12
2007-07-25
2007-07-26

sql   2:
select   *   from   good_day_money   where   moneyOne   >   '0.000 '
返回为
    day             moneyOne               moneyTwo
2006-8-1       11111                       11111
2006-8-2       22222                       22222
2007-7-12     33333                       33333
2007-7-25     44444                       44444
2007-7-26     55555                       55555


问题:
我如何才能在sql   1中把sql   2中查到的记录,但sql   1没有包含近来的,包含近来啊?

------解决方案--------------------
有人看得明嘛??
------解决方案--------------------
substr有这函数吗?
------解决方案--------------------
//??
------解决方案--------------------
select a.day
from good_day_money a
left outer join
(
select substr(b.operdatedate,1,10) 'time '
from card_sale_note d, card_sale_card b, card_type c
where (d.id = b.id and d.if_new_card = b.if_new_card
and b.if_exit_card is null and b.type_id = c.type_id)
and date(b.operdatedate)> =date( '2006-07-27 00:00:00 ')
and date(b.operdatedate) <=date( '2007-07-27 23:59:59 ')
group by substr(b.operdatedate,1,10)
) b
on a.day = b.time