|
|
|
Помогите адаптировать запрос от SQLite к MySQL
|
|||
|---|---|---|---|
|
#18+
Запрос для SQLite на подсчет значения между двумя выбранными датами: ++ WITH RECURSIVE dates(date) AS ( VALUES({edbegdate}) UNION ALL SELECT date(date, '+1 day') FROM dates WHERE date < {edenddate} ) SELECT "date", TOTAL( ( SELECT TOTAL(rent.rent / (julianday(rent."end") - julianday(rent."begin"))) FROM rent WHERE "date" > rent."begin" AND "date" < rent."end" AND (CASE WHEN {ComboBox1}=-1 THEN 1=1 ELSE rent.id_car={ComboBox1} END) ) ) as TotalResult FROM dates +++ MySQL ругается на синтаксис Что нужно изменить? ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 08.02.2016, 22:32:59 |
|
||
|
Помогите адаптировать запрос от SQLite к MySQL
|
|||
|---|---|---|---|
|
#18+
kostas2016, да все тут надо менять, рекурсивных запросов нет в mySQL, так что надо все переписывать, в зависимости от семантики тут может быть что угодно от совсем просто до вообще невозможно. также могут быть проблемы с данными т. к. рекурсивные запросы могут строки данных, а в бд данных таких может не быть. ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 08.02.2016, 22:40:03 |
|
||
|
Помогите адаптировать запрос от SQLite к MySQL
|
|||
|---|---|---|---|
|
#18+
MasterZiv, похоже рекурсивный подзапрос генерирует все даты в диапазоне, в общем, наверное сразу лучше нагенирить их в какой-то табличке на год вперед, и использовать. Потом еще на год и т. д. ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 08.02.2016, 22:43:56 |
|
||
|
Помогите адаптировать запрос от SQLite к MySQL
|
|||
|---|---|---|---|
|
#18+
select SUM( ( SELECT SUM(rent.rent / (datediff(rent.`end`, rent.`begin`)+1)) FROM rent WHERE `selected_date` >= rent.`begin` AND `selected_date` <= rent.`end` AND (CASE WHEN {ComboBox1}=-1 THEN 1=1 ELSE rent.id_car={ComboBox1} END) ) ) from (select adddate('1970-01-01',t4.i*10000 + t3.i*1000 + t2.i*100 + t1.i*10 + t0.i) selected_date from (select 0 i union select 1 union select 2 union select 3 union select 4 union select 5 union select 6 union select 7 union select 8 union select 9) t0, (select 0 i union select 1 union select 2 union select 3 union select 4 union select 5 union select 6 union select 7 union select 8 union select 9) t1, (select 0 i union select 1 union select 2 union select 3 union select 4 union select 5 union select 6 union select 7 union select 8 union select 9) t2, (select 0 i union select 1 union select 2 union select 3 union select 4 union select 5 union select 6 union select 7 union select 8 union select 9) t3, (select 0 i union select 1 union select 2 union select 3 union select 4 union select 5 union select 6 union select 7 union select 8 union select 9) t4) v where selected_date between {edbegdate} and {edenddate} ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 10.02.2016, 03:56:48 |
|
||
|
|

start [/forum/topic.php?fid=47&fpage=111&tid=1832176]: |
0ms |
get settings: |
8ms |
get forum list: |
19ms |
check forum access: |
4ms |
check topic access: |
4ms |
track hit: |
84ms |
get topic data: |
8ms |
get forum data: |
2ms |
get page messages: |
28ms |
get tp. blocked users: |
2ms |
| others: | 237ms |
| total: | 396ms |

| 0 / 0 |
