sql - 将 SQL Server / C# 查询转换为 PostgreSQL
问题描述
我是 postgres 的新手,我遇到了一个问题,但我在这里找到了解决方案: https ://stackoverflow.com/a/31841098/15663795
但问题是这个查询不在 PostgreSQL 中。有人可以帮助转换此查询吗?
with [TimeSlotCTE] as
(
-- Base case: the first appointment slot of the day.
select
[From] = @StartTime,
[To] = dateadd(minute, @DesiredLength, @StartTime)
union all
-- Recursive case: create a subsequent appointment slot as long as doing so won't
-- take us past the office's closing time.
select
dateadd(minute, @Interval, [From]),
dateadd(minute, @Interval, [To])
from
[TimeSlotCTE]
where
dateadd(minute, @Interval, [To]) <= @EndTime
)
我试过这个:
WITH TIMESLOTS AS
(SELECT * FROM (VALUES('09:00','09:30')) BASE("start","end")
UNION ALL SELECT "start" + interval '30 minutes',
"end" + interval '30 minutes')
SELECT *
FROM TIMESLOTS;
但它显示以下错误
column "start" does not exist
解决方案
推荐阅读
- plsql - 如何解决这个 pl sql oracle 查询?
- android - SQLite 清除缓存后从 Assets 中读取 base
- ios - Xcode 10 不象征崩溃日志
- javascript - 在现有状态转换期间无法更新,另外函数作为布尔值传递,我不知道为什么
- gitlab - lftp 在 gitlab-ci 中运行失败,返回 shell not found
- hyperledger-fabric - 在 Fabric 中,链码版本控制如何在内部发生?
- elasticsearch - 如何在 Golang 中使用 Olivere 将数据插入 Elasticsearch
- c# - 如何修复错误“UpdateCommand 已影响 1 个预期条目中的 0 个。”?
- node.js - 如何在“真实世界”时间内每 n 毫秒准确地调用一个函数?
- java - 为什么 Switch case 在正常课堂上不起作用?