×

Loading...

please try the whole comment, statement in () can inherit those alias like "t1"defined outside, I guess you are a new guy, and havn't got the sql sever here, but I do, and try the statement already. Trust me.

tuantuan (团团)
本文发表在 rolia.net/zh 相约加拿大网上社区枫下论坛
my work result in sql server.
select * from employee
empname depname empsalary
-------------------- -------------------- --------------------
Mike A 1000
Tom A 1100
Jame A 1800
Peter A 2000
Bob B 1900
Alice B 2200
Ben B 1000
Joe B 1300

(8 row(s) affected)

select * from employee t1 where t1.empsalary >
(select avg(empsalary) from employee t2 where t2.depname = t1.depname )


empname depname empsalary
-------------------- -------------------- --------------------
Jame A 1800
Peter A 2000
Bob B 1900
Alice B 2200

(4 row(s) affected)
更多精彩文章及讨论,请光临枫下论坛. 网址: rolia.net/zh
(#28841@0)
2001-2-26 -04:00
This post has been archived. It cannot be replied.
Page address has been copied. To share, click to copy page address.
Share Online by QR Code

Back To Topic: help! SQL assignment due tomorrow...

Back To Forum: HOME枫下论坛枫下论坛主坛工作学习IT技术讨论