运行此脚本时出错:
WITH q AS (
SELECT COUNT(id)
FROM test
)
SELECT 1,
CASE
WHEN q=0 then 'toto'
ELSE 'titi'
END
FROM dual;
我必须使用子查询因子(WITH
)条款。
想法是当计数等于0时显示'toto'
,否则我必须显示'titi'
。
答案 0 :(得分:2)
为结果使用别名,并FROM q
WITH q AS (
SELECT COUNT(id) as total
FROM test
)
SELECT 1,
CASE
WHEN q.total = 0 THEN 'toto'
ELSE 'titi'
END
FROM q;
答案 1 :(得分:2)
您可以将其简化为:
<%= ..., name: "user_item_images_attributes[picture][]", ... %>
您的查询中的错误是您创建了一个已命名的子查询 $(function () {
$('#container').highcharts({
chart: {
type: 'area'
},
xAxis: {
min: 0,
max: 100,
pointRange:10,
title: {
text: 'Time'
}
},
yAxis: {
title: {
text: 'Power'
}
},
plotOptions: {
area: {
stacking: 'normal',
lineWidth: 0,
marker: {
enabled: true,
symbol: 'circle',
radius: 0
}
}
},
series: [{
data: [
[0, 2500],
[10, 2600],
[20, 2700],
[30, 2800],
[40, 2900],
[50, 3000],
[60, 3100],
[70, 3200],
[80, 3300],
[90, 3400],
[100, 3500],
],
color: '#FF0000',
negativeColor: '#1B8753',
threshold: 3000
}]
});
});
但是您正在从SELECT 1,
CASE COUNT(*) WHEN 0 then 'toto' ELSE 'titi' END
FROM test;
表中选择列q
(该列没有列{{ 1}})。
您可以像这样修复查询:
q