我有两个输入日期作为参数,我的查询应返回两个日期之间的上一个季度结束日期。 我们一年有四个季度。
Q1 -Jan to March
Q2-Apr to June
Q3-Jul to Sep
Q4-Oct to Dec
输入日期Q1-2015,2016年第2季度
从查询中返回的日期数
Dec 31st 2014
March 31st 2015
June 30 2015
Sep 30 2015
Dec 31st 2015
March 31st 2016
输入日期 2016年第二季度2016年第二季度
Number of Dates to be returned from query
Dec 31st 2015
March 31 2016
我需要在查询中返回它。 谢谢你的帮助。
答案 0 :(得分:0)
下面的解决方案将输入作为绑定变量。它仅适用于输入完全采用该格式(七个字符的字符串# Package source URL: http://cran.r-project.org/web/packages/ggmap/ggmap.pdf
# Data source URL: http://www.geo.ut.ee/aasa/LOOM02331/heatmap_in_R.html
install.packages("ggmap")
library(ggmap)
# load the data
tartu_housing <- read.csv("data/tartu_housing_xy_wgs84_a.csv", sep = ";")
# Download the base map
tartu_map_g_str <- get_map(location = "tartu", zoom = 13)
# Draw the heat map
ggmap(tartu_map_g_str, extent = "device") + geom_density2d(data = tartu_housing, aes(x = lon, y = lat), size = 0.3) +
stat_density2d(data = tartu_housing,
aes(x = lon, y = lat, fill = ..level.., alpha = ..level..), size = 0.01,
bins = 16, geom = "polygon") + scale_fill_gradient(low = "green", high = "red") +
scale_alpha(range = c(0, 0.3), guide = FALSE)
, function create_worker()
{
echo "Generate the Kubernetes Worker Keypairs ...";
WORKER_NUMBER=2
WORKERS_FQDN=("worker1" "worker2" "worker3")
WORKERS_IP=("192.168.0.10" "192.168.0.11" "192.168.0.12")
MASTER_IP=("192.168.0.20")
K8S_SERVICE_IP=10.3.0.1
for ((i=0; i <= "$WORKER_NUMBER"; i++));
do
echo "${WORKERS_IP[i]}" --- "${WORKERS_FQDN[i]}";
openssl genrsa -out "${WORKERS_FQDN[i]}"-worker-key.pem 2048
WORKER_IP="${WORKERS_IP[i]}" openssl req -new -key "${WORKERS_FQDN[i]}"-worker-key.pem -out "${WORKERS_FQDN[i]}"-worker.csr -subj "/CN="${WORKERS_FQDN[i]}"" -config worker-openssl.cnf
WORKER_IP="${WORKERS_IP[i]}" openssl x509 -req -in "${WORKERS_FQDN[i]}"-worker.csr -CA ca.pem -CAkey ca-key.pem -CAcreateserial -out "${WORKERS_FQDN[i]}"-worker.pem -days 365 -extensions v3_req -extfile worker-openssl.cnf
sleep 2;
done
为1到4且'Qx-yyyy'
为有效年份)且仅在&# 34;与季&#34;等于或晚于&#34;来自四分之一&#34 ;;我的解决方案没有进行任何验证以确保是这种情况,并且违反这些规则的行为是未定义的(这意味着我没有花时间测试任何&#34;规则破坏&#34;案例)
x
注意:如果您不能使用逐级连接,则可以不使用它,但您需要一种机制来生成从1到足够高限制的数字。您可以对yyyy
表进行硬编码(类似于下面的表),也可以使用某种机制从具有多行的表中读取行号。这是一个可能的解决方案:
with
prep ( from_qtr, from_yr, to_qtr, to_yr ) as (
select to_number(substr(:from_year, 2, 1)),
to_number(substr(:from_year, 4 )),
to_number(substr(:to_year , 2, 1)),
to_number(substr(:to_year , 4 ))
from dual
)
select add_months( to_date(to_char(from_yr) || '/' || to_char(3 * from_qtr - 2)
|| '/01', 'yyyy/mm/dd') - 1,
3 * (level - 1)
) as qtr_end_date
from prep
connect by level <= 1 + 4 * (to_yr - from_yr) + (to_qtr - from_qtr)
order by qtr_end_date
;
硬编码的替代方法是num
,您需要有足够的数字来涵盖所有可能的情况。
答案 1 :(得分:0)
这正是需要的,我正在查看sybase.do,我们已经在Sybase中连接。