mirror of
https://github.com/rjNemo/rentease.git
synced 2026-06-06 02:36:49 +00:00
improve the report sql query
This commit is contained in:
parent
68df2f06a2
commit
ea039dc428
1 changed files with 5 additions and 8 deletions
|
|
@ -118,14 +118,11 @@ func (bs Service) BuildReport(period string, month, year int) *Report {
|
|||
}
|
||||
|
||||
bs.db.Raw(`
|
||||
select id, customer_name, "from", "to", platform, total, platform_fees
|
||||
from (select sum(price*quantity) as total, booking_id
|
||||
from bookings
|
||||
join items on bookings.id = items.booking_id
|
||||
where "from" between ? and ?
|
||||
group by booking_id) as sbi,
|
||||
(select * from bookings) as b
|
||||
where sbi.booking_id = b.id;
|
||||
select bookings.id, customer_name, "from", "to", platform, sum(price * quantity) as total, platform_fees
|
||||
from bookings
|
||||
join items on bookings.id = items.booking_id
|
||||
where "from" between ? and ?
|
||||
group by bookings.id;
|
||||
`,
|
||||
startDate.Format("2006-01-02"), endDate.Format("2006-01-02")).
|
||||
Scan(&lines)
|
||||
|
|
|
|||
Loading…
Reference in a new issue