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

求最在值有关问题.为什么不对呢.请帮忙看看.多谢了

2012-01-14 
求最在值问题.为什么不对呢.请帮忙看看.谢谢了!selectMax(kian_date)asMaxKianDatefrom(((selecta.KIAN_DA

求最在值问题.为什么不对呢.请帮忙看看.谢谢了!
select   Max(kian_date)   as   MaxKianDate     from
(
(
(
select   a.KIAN_DATE   as   KIAN_DATE   from   RINGI_TBL   a,RINGIMEISAI_TBL   b,FAVORITES_TBL   c   where  
c.SYSYNO=a.KIANSYA_CODE   and   c.KANRISYA_CODE=b.KAIGISYA_CODE   and   a.ID=b.ID
)  
Union
(
select   d.HOKOKU_DATE   as   KIAN_DATE   from   HOKOKU_TBL   d,HOKOKUMEISAI_TBL   e,FAVORITES_TBL   f   where  
f.SYSYNO=d.HOKOKUSYA_CODE   and   f.KANRISYA_CODE=e.KAIGISYA_CODE   and   d.ID=e.ID
)    
)
)   as   tt   group   by   tt.kian_date

[解决办法]
select
Max(kian_date) as MaxKianDate
from
(select a.KIAN_DATE as KIAN_DATE
from RINGI_TBL a,RINGIMEISAI_TBL b,FAVORITES_TBL c
where c.SYSYNO=a.KIANSYA_CODE and c.KANRISYA_CODE=b.KAIGISYA_CODE and a.ID=b.ID
Union
select d.HOKOKU_DATE as KIAN_DATE
from HOKOKU_TBL d,HOKOKUMEISAI_TBL e,FAVORITES_TBL f
where f.SYSYNO=d.HOKOKUSYA_CODE and f.KANRISYA_CODE=e.KAIGISYA_CODE and d.ID=e.ID) as tt

热点排行