在元数据库中设置一个下拉菜单,该菜单中只包含月份值(1月至12月)PostgreSQL
我目前正在尝试做一个下拉菜单,专门为几个月 下面是我的代码:在元数据库中设置一个下拉菜单,该菜单中只包含月份值(1月至12月)PostgreSQL,postgresql,metabase,Postgresql,Metabase,我目前正在尝试做一个下拉菜单,专门为几个月 下面是我的代码: SELECT avg(Monthly_Calls), district, “Crops”, “Months”, “Date” FROM( SELECT date_part(‘month’, t.created_on::date) as “Months”, COUNT(*) AS Monthly_Calls, t.created_on::date as “Date”, district_name as district, date_p
SELECT
avg(Monthly_Calls), district, “Crops”, “Months”, “Date”
FROM(
SELECT date_part(‘month’, t.created_on::date) as “Months”,
COUNT(*) AS Monthly_Calls,
t.created_on::date as “Date”,
district_name as district,
date_part(‘year’, t.created_on::date) as “Years”,
t.crop as “Crops”
FROM t
where true
[[and {{Crops}}]]
[[and date_part(‘month’, t.created_on::date) = {{Months}}]]
GROUP BY district_name, date_part(‘month’, t.created_on::date), date_part(‘year’, t.created_on::date), crop, created_on
)calls
where “Years” between 2012 and 2018
GROUP BY district, “Months”, “Crops”, “Date”, “Years”
我只设法以数字值表示月份,我可以将其返回并显示在区域地图中,但我想使月份成为一个下拉列表,就像由1-12的值组成的作物菜单一样(数据库中不提供月份,数据库只创建了一个日期,即2018-09-12)我正在元数据库中使用PostgreSQL数据库
任何帮助都很好谢谢
下面是本月所需输出的屏幕截图