我::在网上看过各种涉及postgres代码的地方.例如:
SELECT '{apple,cherry apple, avocado}'::text[];
Run Code Online (Sandbox Code Playgroud)
这似乎是某种演员.::postgres 到底是什么时候应该使用它?
我尝试了一些谷歌搜索和搜索Postgres文档,::但没有得到很好的结果.
我尝试在Google中进行搜索:
我在postgres文档搜索按钮中尝试了以下搜索
问这个问题几乎令人尴尬,但我认为Google希望将来能够为其他人看到这个答案.
我的数据库是Postgres 8.我需要将数据类型转换为另一个.这意味着,列数据类型之一是varchar并且需要int在SELECT语句中将其转换为Postgres .
目前,我获取字符串值并将其转换int为Java.
有什么办法吗?示例代码将受到高度赞赏.
我在命令提示符下运行了sqlite3并运行了一些基本的SQL命令.
user@comp:~$ sqlite3
SQLite version 3.8.2 2013-12-06 14:53:30
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> CREATE TABLE A (a int, b text, c float);
sqlite> INSERT INTO A(a,b,c) VALUES (1, '2', 3);
sqlite> SELECT b::int+2 FROM A;
Run Code Online (Sandbox Code Playgroud)
除了最后一行之外,所有行都有效,它给出了错误:`
错误:无法识别的令牌:":"`
这是我的SQL查询的摘录
SELECT
date_trunc(
'day',
to_timestamp(requests.date_created)
)AS DAY,
Run Code Online (Sandbox Code Playgroud)
这是我的输出
2013-02-04 00:00:00+00
我希望这只是公正的
2013-02-04
我如何获得理想的结果?
我有下面的查询,它正常工作,但不知道::在postgresql中的含义和用法.
select (
select (
case when 1 > 0 then 1::float / (
select count(id) from transactions_products where transaction_id in (
select id from transactions_transactions tt
where status = 3 and fi = 355
and (invoice_date >= 1420754400)
and (invoice_date <= 1421099999)
and (tt.division_id = 107)
and (tt.department_id = 210)
) and is_vehicle = 1
)::float else 0 end)
limit 1) as f_4
Run Code Online (Sandbox Code Playgroud)