基于多列打印值

时间:2017-07-22 16:10:12

标签: c# sql asp.net linq-to-sql

我的桌子

+----+----------+---------+---------+----------+
| ID | State A  | State B | State C | Duration |
+----+----------+---------+---------+----------+
| 1  |     a    |    a    |    a    |    12    |
+----+----------+---------+---------+----------+
| 2  |     a    |    a    |    a    |    15    |
+----+----------+---------+---------+----------+
| 3  |     a    |    a    |    b    |    12    |
+----+----------+---------+---------+----------+
| 4  |     a    |    b    |    b    |    30    |
+----+----------+---------+---------+----------+
| 5  |     b    |    b    |    b    |    12    |
+----+----------+---------+---------+----------+

如果3列具有相同的值和持续时间< 15 结果如下:

+----+-----------------+
| ID |    THE RESULT   |
+----+-----------------+
|  1 | a is the winner |
+----+-----------------+

1 个答案:

答案 0 :(得分:0)

这是一个过滤器以及concat()

select concat(statea, ' is the winner')
from t
where statea = stateb and stateb = statec and duration < 15