我试图在Microsoft Access中使用内部联接从三个表中进行选择。在其中一个字段中,我还需要选择它返回的记录数。
SELECT Person.FirstName, Person.LastName, Person.Phone,
Person.Email,Person.Address, Room.RoomNo, Room.Type, Building.Name,
Floor.Name,count(*) as result
FROM (Floor INNER JOIN (Building INNER JOIN
Room ON Building.BuildingID = Room.BuildingID) ON Floor.FloorNo =
Room.FloorNo) INNER JOIN (Person INNER JOIN Patient ON Person.Username =
Patient.Username) ON Room.RoomNo = Patient.RoomNo
WHERE (((Person.FirstName) Like "*" & [Forms]![search]![firstnameKey] & "*")
AND ((Person.LastName) Like "*" & [Forms]![search]![lastnameKey] & "*")) AND
(patient.status = 1)
GROUP BY Patient.username ;
答案 0 :(得分:1)
只要您拥有汇总功能,您就必须puts Rails::Server.new.options[:Port]
未计算的字段。只需查看您的select语句,您就会返回多个字段,即:group by
等。我相信您必须Person.Firstname, Person.Lastname
这些非聚合字段。
示例代码:
group by