【发布时间】:2022-11-13 01:44:08
【问题描述】:
As the title says, I am trying to create a column with the names of variables counted from an interjoin.
This is the code I used:
select
count(customer.age) from customer
inner join services on customer.customer_id = services.customer_id
where age > 64
GROUP BY
services.internetservices;
This is the output as internetservices has 3 data variables.
"count"
1155
1485
740
如何创建一个包含变量名称(值?)的列?谢谢你的帮助!我对 SQL 很陌生,希望一切都尽可能简单!
【问题讨论】:
-
我不明白这个问题。您正在显示计数,但您不知道哪个数字指的是哪个互联网服务。所以,
select services.internetservices, count(*) as customers from ...。这是否已经回答了您的问题? -
附带说明:将人员年龄存储在表格中很奇怪,因为您必须每天检查数据才能调整年龄。您应该存储生日,以便在需要时计算年龄。
标签: postgresql count inner-join