首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > SQL Server >

高手快帮帮小弟我

2012-01-09 
高手快帮帮我描述如下:sql1:selectsubstr(b.operdatedate,1,10)timefromcard_sale_noted,card_sale_cardb,

高手快帮帮我
描述如下:
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

热点排行