日期:2014-05-18  浏览次数:20558 次

SQL 语句出错``````这里人多``在线揭贴`
select   seqn_num,subject,to_char(Execute_time, 'hh24:mi:ss '),text,is_finish   from   t_mission   where     to_char(Execute_time, 'hh24 ')=8   and   to_date(to_char(Execute_time, 'yyyy-mm-dd '), 'yyyy-mm-dd ')=to_date( '2007-7-15 ', 'yyyy-mm-dd ')   order   by   Execute_time

当我这样执行的时候是对的``   我要去掉subject重复的怎么写?

select     seqn_num,distinct   subject,to_char(Execute_time, 'hh24:mi:ss '),text,is_finish   from   t_mission   where     to_char(Execute_time, 'hh24 ')=8   and   to_date(to_char(Execute_time, 'yyyy-mm-dd '), 'yyyy-mm-dd ')=to_date( '2007-7-15 ', 'yyyy-mm-dd ')   order   by   Execute_time     是错的```


------解决方案--------------------
非技術版?
------解决方案--------------------
select seqn_num,subject,to_char(Execute_time, 'hh24:mi:ss '),text,is_finish
from t_mission t
where to_char(Execute_time, 'hh24 ')=8 and to_date(to_char(Execute_time, 'yyyy-mm-dd '), 'yyyy-mm-dd ')=to_date( '2007-7-15 ', 'yyyy-mm-dd ')
--and (select count(subject) from t_mission where t.subject=subject)=1 加上这句试试
order by Execute_time
------解决方案--------------------
转到oracle版吧

问题也许没说清楚,去掉subject重复,其他字段怎么取,说清楚解决起来快点,事半功倍