Join2表和按日期分组

时间:2019-04-28 07:56:32

标签: php mysqli

我想对所有win_ticket求和并将其除以2表中所有sold_ticket的总和,以获得百分比,然后按日期将其分组。

这根本不起作用.....

sold_ticket

enter image description here

customer_winner

enter image description here

$query = "SELECT 
      sold_ticket.date, sold_ticket.sold_ticket, 
              SUM(sold_ticket) AS sold_ticket, 
      customer_winner.date, customer_winner.win_ticket, 
              SUM(win_ticket) AS lottery_win

      FROM sold_ticket

      INNER JOIN customer_winner

      ON sold_ticket.date = customer_winner.date

      GROUP BY date 
      ";

1 个答案:

答案 0 :(得分:0)

需要将sold_ticket.date或customer_winner.date或两者分组。

尝试

Message: Expected item[0] to be "Jonathan" with a length of 8, but "John" has a length of 4, differs near "hn" (index 2).

With configuration:
- Use declared types and members
- Compare enums by value
- Include all non-private properties
- Include all non-private fields
- Match member by name (or throw)
- Without automatic conversion.
- UnitTestProject15.CustomerEmployeeComparer
- Without automatic conversion.
- Always be strict about the collection order