我无法使我的sql case表达式起作用。当我使用此sql语句时,它可以正常工作:
SELECT
TimeInt AS time,
oV101DirectionA,
oV101DirectionB,
id
FROM
machine_data
WHERE
id%1=0 AND
machine_id = 3 AND
$__unixEpochFilter(TimeInt) = TRUE
GROUP BY DATE_FORMAT(TimeStr, '%Y%m%d%k%i')
ORDER BY TimeInt ASC
但是当我修改代码以更好地缩放时,则不会显示任何数据,这也不是错误。如果两个日期之间的时间窗口(以秒为单位)相距甚远,则应跳过数据库中的行以获得更好的性能。
SELECT
TimeInt AS time,
oV101DirectionA,
oV101DirectionB,
id
FROM
machine_data
WHERE
CASE WHEN ($__unixEpochTo(TimeInt)-$__unixEpochFrom(TimeInt)) > 100 THEN 'id%10 = 0'
WHEN ($__unixEpochTo(TimeInt)-$__unixEpochFrom(TimeInt)) > 1000 THEN 'id%100 = 0'
ELSE 'id%1 = 0'
END AND
machine_id = 3 AND
$__unixEpochFilter(TimeInt) = TRUE
GROUP BY DATE_FORMAT(TimeStr, '%Y%m%d%k%i')
ORDER BY TimeInt ASC
我已经在线阅读了很多有关sql中的case语句的信息,但是找不到针对我特定问题的答案。
答案 0 :(得分:0)
我怀疑这就是您想要的:
public function onKernelException(GetResponseForExceptionEvent $event)
{
// how to know if $event this happened after/during kernel.terminate?
}
答案 1 :(得分:0)
您不能以这种方式使用bool operator <(Employee const & lhs, Employee const & rhs) {
return lhs.combined_name() < rhs.combined_name();
}
// a.k.a. std::swap
void swap(Employee & lhs, Employee & rhs) {
Employee temp(static_cast<Employee&&>(lhs)); // a.k.a. std::move
lhs = static_cast<Employee&&>(rhs);
rhs = static_cast<Employee&&>(temp);
}
void bubble_sort_impl(Employee * begin, Employee * end) {
for (; end != begin; --end) {
for (Employee * it = begin; it+1 != end; ++it) {
if (*(it+1) < *it) {
swap(*it, *(it+1));
}
}
}
}
// do we really need "bubble_" or "_address_book" in this name?
void AddressBook::bubble_sort_address_book() {
bubble_sort_impl(employees, employees + noOfEmployees);
}
表达式,因为它的输出是 value ,而不是逻辑条件。但是我们可以将您的CASE
逻辑改写为:
WHERE