2012-08-10 80 views
-1

我正在使用SQL Server。我有以下查詢:SQL Server select select無效列名中

select 
    convert(varchar(10), MAX(closedate), 101) 
from 
    (select PSer.Signin_Date as closedate 
    from PSer 
    where ID = '12') 

請注意,我的內容比我的簡化版本更復雜。

我得到一個消息說

無效的列名closedate

回答

0

確保你給你的子查詢的別名。

from (select PSer.Signin_Date as closedate from PSer where ID = '12') AS SOMENAME 
0

使用本:

select convert(varchar(10),MAX(t1.closedate),101) 
from (select PSer.Signin_Date as closedate from PSer where ID = '12') as t1 

享受。