【发布时间】:2017-07-22 16:10:12
【问题描述】:
我的桌子
+----+----------+---------+---------+----------+
| 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 列具有相同的值和持续时间
+----+-----------------+
| ID | THE RESULT |
+----+-----------------+
| 1 | a is the winner |
+----+-----------------+
【问题讨论】:
-
正如您所写:三列具有相同的值和持续时间:
where stata_A = stateB and stateB = stateC amd duration < 15 -
其他行呢
-
您在寻找 linq 还是 SQL 解决方案?如果 linq 你有没有尝试过什么?
-
然后将 WHERE 条件移动到 Select 中:
case when stata_A = stateB and stateB = stateC and duration < 15 then 'is the winner' else '' end
标签: c# sql asp.net linq-to-sql