Railsbin – The vulnerable pastebin service!

User:

Title: test

Content:

SELECT 
  (
    SUM(Orders.shipping_costs)
  ) AS `vsk_ges`, 
  MONTH(`Bills`.`created`) AS `month`, 
  YEAR(`Bills`.`created`) AS `year`, 
  (
    SUM(
      OrderPositions.quantity * OrderPositions.qualification_volume
    )
  ) AS `qualification_volume`, 
  (
    SUM(
      OrderPositions.quantity * OrderPositions.price /(
        1 +(OrderPositions.vat / 100)
      )
    )
  ) AS `sum`, 
  (
    SUM(
      OrderPositions.quantity * OrderPositions.provision_price
    )
  ) AS `provision_price_sum`, 
  (
    SUM(
      OrderPositions.quantity * OrderPositions.price
    )
  ) AS `brut_sum` 
FROM 
  `bills` `Bills` 
  LEFT JOIN `orders` `Orders` ON Orders.id = Bills.ReferenceKey 
  LEFT JOIN `order_positions` `OrderPositions` ON Orders.id = OrderPositions.order_id 
WHERE 
  `Bills`.`created` BETWEEN '2023-07-01 00:00:00' 
  AND '2024-12-31 23:59:59' 
GROUP BY 
  `month`, 
  `year` 
ORDER BY 
  `Bills`.`created` DESC

Edit | Back