Okay
  Public Ticket #1941989
Complex sql query error
Closed

Comments

  • Plasmid69 started the conversation

    Hi!

    I've tried to create a table from mysql query. the query works fine in phpmyadmin, on the same tables.

    When I enter the same query into the table creation it gives error: below.

    I've tried it with creating a view, but that also gives similar error.

    "
    Error

    cannot calculate position of (2ok) within Union all
    SELECT 2ok as Megállás_oka, count(2ok) as darab, sum(2p) as össz_idő FROM `l60_allasokok_idok` where date(kezdés_dátum) BETWEEN date('2019-02-26 07:30') and date('2019-03-04 05:00') group by 2ok)
    as okok_idok group by Megállás_oka"

    The query:

    "

    SELECT
    Megállás_oka as 'Megok',
    sum(darab) as 'Esetszám',
    sum(össz_idő) as 'Összidő'
    FROM (SELECT 1ok as Megállás_oka, count(1ok) as darab, sum(1p) as össz_idő FROM `l60_allasokok_idok`         where date(kezdés_dátum) BETWEEN date('2019-02-26 07:30') and date('2019-03-04 05:00') group by 1ok         Union all
    SELECT 2ok as Megállás_oka, count(2ok) as darab, sum(2p) as össz_idő FROM `l60_allasokok_idok`         where date(kezdés_dátum) BETWEEN date('2019-02-26 07:30') and date('2019-03-04 05:00') group by 2ok)
            as okok_idok
     group by Megállás_oka

    "

  •  2,572
    Aleksandar replied

    Hello Plasmid69.

    Can you, please, export the database that contain these tables from PHPMyAdmin and send it to me, so I can try it locally?

    Just make sure to enable the Private slider when you respond, so no one else can see it but us.

    Best regards.

    Kind Regards, 

    Aleksandar Vuković
    [email protected]

    Rate my support

    wpDataTables: FAQ | Facebook | Twitter | InstagramFront-end and back-end demo | Docs

    Amelia: FAQ | Facebook | Twitter | InstagramAmelia demo sites | Docs | Discord Community

    You can try wpDataTables add-ons before purchasing on these sandbox sites:

    Powerful Filters | Gravity Forms Integration for wpDataTables | Formidable Forms Integration for wpDataTables | Master-Detail Tables