select extract (year from CRIME_DATE) year,
SUM (CRIME_NO)
from crime
group by select extract (year from CRIME_DATE) CRIME_DATE
order by select extract (year from CRIME_DATE) year
我正在尝试使用上面的查询在apex中的应用程序构建器中生成一个图表,但是为了确保它正常工作我在SQL命令上测试它但是我一直得到丢失的表达式错误,任何人都可以帮忙吗?
答案 0 :(得分:2)
select extract (year from CRIME_DATE) year,
SUM (CRIME_NO)
from crime
group by extract (year from CRIME_DATE)
order by extract (year from CRIME_DATE)
这应该解决问题。在按顺序/按顺序提取后,您有其他列名称(如果您希望通过逗号使用多列来标识这些列),并且它们也应该在该行中有选择。
对于图表错误....也许试试这个(在Oracle上有点生疏,所以不确定这会有效):
select extract (year from CRIME_DATE) year,
SUM (CRIME_NO)
from crime
group by extract (year from CRIME_DATE)
order by year
答案 1 :(得分:0)
仅解决图表错误 - Marshall Tigerus解决了您的初始错误 - 图表构建器中的错误非常清楚,并且有样本。您需要使用特定的列别名;你还需要COUNT
而不是SUM
,我认为:
select NULL link,
extract (year from CRIME_DATE) label,
COUNT (CRIME_NO) value
from crime
group by extract (year from CRIME_DATE)
order by extract (year from CRIME_DATE);