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

一道题,不知错哪里
一道题:找出价格最高的产品(PC、笔记本电脑或打印机)的型号

我这样写是对的:
C/C++ code

select model 
from
(
    (select model,price from PC)
    UNION
    (select model,price from Laptop)
    UNION
    (select model,price from Printer)
)M
where
(
    M.price>=ALL
    (
        select price from
        (
            (select price from PC)
            UNION
            (select price from Laptop)
            UNION
            (select price from Printer)
        )R
     )
)



但是我这样改一下,就报错:
消息 156,级别 15,状态 1,第 11 行
关键字 'ALL' 附近有语法错误。
消息 102,级别 15,状态 1,第 21 行
'<' 附近有语法错误。

C/C++ code

select model 
from
(
    (select model,price from PC)
    UNION
    (select model,price from Laptop)
    UNION
    (select model,price from Printer)
)M
where
(
    ALL
    (
        select price from
        (
            (select price from PC)
            UNION
            (select price from Laptop)
            UNION
            (select price from Printer)
        )R
     )<=M.price
)




请问大家,我哪里错了吗?

------解决方案--------------------
SQL code

--这是一种语法,就像datepart(day,getdate())一样,你不可以把它放错位置
scalar_expression { = | < > | ! = | > | > = | ! > | < | < = | ! < } 
     { ALL | SOME | ANY } ( subquery )