选择条件-Sql server

时间:2014-06-12 14:42:10

标签: sql-server

我有一个表test,如下所示

Contract   date_prolog    hours 
-------------------------------
No                         20
Yes         24/02/2014     10
No                         30
No                         10

如何获得此结果?

Contract   date_prolog    hours 
-------------------------------
No          24/02/2014     20
No          24/02/2014     30
No          24/02/2014     10

1 个答案:

答案 0 :(得分:1)

select contract, 
       (select date_prolog from test where contract = 'yes') as date_prolog, 
       hours
from test
where contract = 'no'