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

归并两句话

2013-01-11 
合并两句话create table tmp asselect code, round((max(close)-min(close))/min(close),2) as volatility

合并两句话
create table tmp as  select code  , round((max(close)-min(close))/min(close),2) as volatility,
    case  when  (max(close)-min(close))/min(close) <0.1  then  "grade1" 
    when  (max(close)-min(close))/min(close)       <0.2  then  "grade2"
    when  (max(close)-min(close))/min(close)       <0.3  then  "grade3"
    else "grade4"  end  as  type
    from  quote  where date between '20120801' and '20121101' and code<'07000'  
    group by code order by volatility ;

select  tmp.code,profile.name, tmp.volatility from tmp,profile where tmp.code=profile.code;

 select quote.code ,profile.name, round((max(quote.close)-min(quote.close))/min(quote.close),2) as quote.volatility,
    case  when  (max(quote.close)-min(quote.close))/min(quote.close) <0.1  then  "grade1" 
    when  (max(quote.close)-min(quote.close))/min(quote.close)       <0.2  then  "grade2"
    when  (max(quote.close)-min(quote.close))/min(quote.close)       <0.3  then  "grade3"
    else "grade4"  end  as  quote.type
    from  quote,profile where quote.date between '20120801' and '20121101' and quote.code<'07000' and quote.code=profile.code
    group by quote.code order by quote.volatility ;

我的第一句,第二句话都可以运行,合并成第三句,为何就不能运行了?
[解决办法]
 select quote.code ,profile.name, round((max(quote.close)-min(quote.close))/min(quote.close),2) as quote.volatility,
     case  when  (max(quote.close)-min(quote.close))/min(quote.close) <0.1  then  "grade1" 
     when  (max(quote.close)-min(quote.close))/min(quote.close)       <0.2  then  "grade2"
     when  (max(quote.close)-min(quote.close))/min(quote.close)       <0.3  then  "grade3"
     else "grade4"  end  as  quote.type
     from  quote,profile where quote.date between '20120801' and '20121101' and quote.code<'07000' and quote.code=profile.code
     group by quote.code,profile.name order by quote.volatility ;

热点排行