所以我想只显示2个键值对,如果他们的日期是相同的。因此,举例来说,如果一个键值对不具有完全相同的日期,时间,另一键值对,那就不要让他们在所有...如何选择日期相同的2个键值对的值?
所以我的逻辑如下,但我不知道如何实现它:
SELECT ForeignKeyID, Value, Date
FROM tblMyTable
//declare myDate= null ????
where (ForeignKeyID = 1 and Value > 14) or (ForeignKeyID = 2 and Value > 10)
//somehow check if myDate from the first key-value pair has the exact same myDate as the second one or vice versa.
这里是我想要的,不想显示:
Time ForeignKeyID Value
2015-05-27 00:30:00.000 1 15.000 //Yes because same date for 2 exists
2015-05-27 00:30:00.000 2 13.800 //Yes because same date for 1 exists
2015-05-27 00:45:00.000 1 15.000 //Yes
2015-05-27 00:45:00.000 2 13.800 //Yes
2015-05-27 01:00:00.000 1 15.000 //Yes
2015-05-27 01:00:00.000 2 13.300 //Yes
2015-05-27 01:15:00.000 1 15.000 //Yes
2015-05-27 01:15:00.000 2 13.300 //Yes
2015-05-27 01:30:00.000 2 13.300 //No because the same date for 1 doesnt exist!
2015-05-27 01:45:00.000 2 13.300 //No because the same date for 1 doesnt exist!
2015-05-27 02:00:00.000 1 15.000 //No because the same date for 2 doesnt exist!
2015-05-27 02:15:00.000 1 15.000 //No because the same date for 2 doesnt exist!
在这里我的无知,实在不好意思,但我想在这里学习...
谷歌和了解SQL中的WHERE EXISTS()函数。 –