我正在使用 Viescas 的SQL Queries for Mere Mortals及其数据集。
如果我运行他的代码:
select customers.CustFirstName || " " || customers.CustLastName as "Name",
customers.CustStreetAddress || "," || customers.CustZipCode || "," || customers.CustState as "Address",
count(engagements.EntertainerID) as "Number of Contracts",
sum(engagements.ContractPrice) as "Total Price",
max(engagements.ContractPrice) as "Max Price"
from customers
inner join engagements
on customers.CustomerID = engagements.CustomerID
group by customers.CustFirstName, customers.custlastname,
customers.CustStreetAddress,customers.CustState,customers.CustZipCode
order by customers.CustFirstName, customers.custlastname;
我得到类似于下表的内容:
名称 地址 合约数量 总价 最高价
0 1 7 8255.00 2210.00
0 1 11 11800.00 2570.00
0 1 10 12320.00 2450.00
0 1 8 10795.00 2750.00
0 1 8 25585.00 14105.00
0 1 6 7560.00 2300.00
但是,第一行应该在 Name 列中输出了 Carol Viescas... 为什么我们得到的却是零?