SELECT
StaffID,
SUM(Treatment.TreatmentPrice) AS TotalStaffRevenue,
SUM(Treatment.TreatmentPrice) * ? AS Commission
FROM
Treatment
INNER JOIN
Appointment ON Appointment.TreatmentID = Treatment.TreatmentID
WHERE
AppointmentDate >= '2018/05/11'
AND AppointmentDate <= '2018/05/12'
GROUP BY
staffid WITH ROLLUP
CREATE TABLE Staff (
StaffID int IDENTITY NOT NULL,
Forename varchar(20) NOT NULL,
Surname varchar(20) NOT NULL,
MobileNumber varchar(11) NOT NULL,
EmailAddress varchar(20) NULL,
PostCode varchar(8) NULL,
HouseNumber varchar(4) NULL,
Commission decimal(6,2) NOT NULL,
PRIMARY KEY(StaffID)
);
GO
CREATE TABLE Treatment (
TreatmentID int identity NOT NULL,
TreatmentName varchar(20) NOT NULL,
TreatmentPrice money NOT NULL,
CategoryID int NOT NULL,
TreatmentDescription varchar(40) NOT NULL,
PRIMARY KEY(TreatmentID, CategoryID)
);
GO
CREATE TABLE Appointment (
AppointmentID int IDENTITY NOT NULL,
StaffID int NOT NULL,
TreatmentID int NOT NULL,
CustomerID int NOT NULL,
AppointmentDate date NOT NULL,
AppointmentTime time(0) NOT NULL,
PRIMARY KEY (AppointmentID, StaffID, CustomerID, TreatmentID)
);
我希望能够将StaffPrice的总和乘以Staff.Commission。我已经尝试了INNER JOINING with Staff但它仍然无法工作如何在前端实现这个(c#)我会为每个循环使用a,然后填充数据网格。