【发布时间】:2019-05-21 09:04:32
【问题描述】:
我正在尝试将列 unixtime 数据转换为 'YYYY-MM-DD' 格式,但没有得到它。我的列的数据类型是数字。
我尝试了以下查询,但出现错误:
select to_timestamp(starttime,'YYYY-MM-DD') , count(*) from cdrs_052019 group by 1
查询执行失败
原因:SQL 错误 [42883]:错误:函数 to_timestamp(numeric, 未知)不存在 提示:没有函数匹配给定的名称和 参数类型。您可能需要添加显式类型转换。位置: 8
|starttime |endtime |duration|duration_min|
|----------|----------|--------|------------|
|155694960 |155694960 |0 | |
|155694960 |155694960 |0 | |
|155694960 |155694960 |0 | |
|155694960 |155694960 |0 | |
|155694960 |155694960 |0 | |
|155694960 |155694960 |0 | |
|155694960 |155694960 |0 | |
|155694960 |155694960 |0 | |
|155694960 |155694960 |0 | |
|155694960 |155694959 |1 | |
需要以下格式的结果:
starttime | count(*)
2019-05-01 56666
2019-05-02 77777
2019-05-03 69495
2019-05-04 4447
【问题讨论】:
标签: postgresql