нужно чтобы вывод $sum происходил в середине циклов и в сравнении
каким запросом можно вытащить?
SELECT
SUM(rating)
FROM
find_ratings
WHERE
post_id IN (...)
<?php
require_once "vendor/autoload.php";
use PhpOffice\PhpSpreadsheet\Cell\DataType;
use PhpOffice\PhpSpreadsheet\Spreadsheet;
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
use PhpOffice\PhpSpreadsheet\Cell\DefaultValueBinder;
use PhpOffice\PhpSpreadsheet\Cell\Cell;
class MyBinder extends DefaultValueBinder
{
public static function dataTypeForValue($pValue)
{
return DataType::TYPE_STRING;
}
}
$binder = new MyBinder();
Cell::setValueBinder($binder);
$spreadsheet = new Spreadsheet();
$sheet = $spreadsheet->getActiveSheet();
$sheet->getStyle('A1')
->getNumberFormat()
->setFormatCode(\PhpOffice\PhpSpreadsheet\Style\NumberFormat::FORMAT_TEXT);
$sheet->setCellValue('A1', '+5');
$writer = new Xlsx($spreadsheet);
$writer->save('./phpspr.xlsx');
я же правильно понимаю, что в рамках одной страницы никогда не должны смешиваться разные группы?
SELECT
id, vendor_name, model_name, body_type, specifications_name, price,
row_number() OVER (PARTITION BY vendor_name, model_name, body_type ORDER BY min_price_vendor, min_price_model, min_price_body, price, specifications_name) group_pos,
row_number() OVER (PARTITION BY vendor_name, model_name, body_type ORDER BY min_price_vendor, min_price_model, min_price_body, price, specifications_name) / 10 page_number
FROM
(
SELECT *,
MIN(price) OVER win_vendor min_price_vendor,
MIN(price) OVER win_model min_price_model,
MIN(price) OVER win_body min_price_body
FROM
car
WINDOW
win_vendor AS (PARTITION BY vendor_name),
win_model AS (PARTITION BY vendor_name, model_name),
win_body AS (PARTITION BY vendor_name, model_name, body_type)
ORDER BY min_price_vendor,
min_price_model,
min_price_body,
price,
specifications_name
) subquery
ORDER BY min_price_vendor,
min_price_model,
min_price_body,
price,
specifications_name