-
Notifications
You must be signed in to change notification settings - Fork 0
/
question3_C_1.sql
22 lines (22 loc) · 954 Bytes
/
question3_C_1.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
SELECT c.id as customerID,
c.forename as customerName,
c.surname as customerSurnmae,
count(price) as totalAmount,
summary.mySum as totalIncome
FROM bedirhan_bardakci.sale s
Join bedirhan_bardakci.stock st on st.id = s.stock_id
join bedirhan_bardakci.book bo on bo .id = st.book_id
join bedirhan_bardakci.salesman sman on sman .id = s.salesman_id
join bedirhan_bardakci.customer c on C .id = s.customer_id
,(
SELECT c.id , c.forename , c.surname , sum(price) as mySum
FROM bedirhan_bardakci.sale s
Join bedirhan_bardakci.stock st on st.id = s.stock_id
join bedirhan_bardakci.book bo on bo .id = st.book_id
join bedirhan_bardakci.salesman sman on sman .id = s.salesman_id
join bedirhan_bardakci.customer c on C .id = s.customer_id
where sman.branch_id = :param_id
group by c.id , c.forename , c.surname
)summary
where summary.id = c.id and sman.branch_id = :param_id
group by c.id , c.forename , c.surname