Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Unrecognized statement type. (near with)

I have query like below for get sum of purchase and sold traffic.

SELECT DATE_FORMAT(order_time,'%d')AS date,
    SUM(CASE WHEN seller_id = 1 THEN visitor_quantity ELSE 0 END) AS totalSold, 
    SUM(CASE WHEN buyer_id = 1 THEN visitor_quantity ELSE 0 END) AS totalBought 
FROM `tbl_orders` 
WHERE buyer_id = 1 OR seller_id = 1 
GROUP BY DATE(order_time) 

Its working fine and giving me result like below
enter image description here

Since I am looking for get all dates between provided date range with 0 if there no any record for that date.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

So I am trying following query

with recursive all_dates(dt) as (
    -- anchor
    select '2021-12-01' dt
        union all 
    -- recursion with stop condition
    select dt + interval 1 day from all_dates where dt + interval 1 day <= '2021-12-31'
)SELECT DATE_FORMAT(order_time,'%d')AS date,SUM(CASE 
    WHEN seller_id = 1 
    THEN visitor_quantity 
    ELSE 0 
END) AS totalSold, SUM(CASE 
    WHEN buyer_id = 1 
    THEN visitor_quantity 
    ELSE 0 
END) AS totalBought FROM `tbl_orders` WHERE buyer_id = 1 OR seller_id = 1 GROUP BY DATE(order_time)

I have found query tutorial here.

But its giving me error called Unrecognized statement type. (near with) in phpmyadmin and giving same result as above image.

my phpmyadmin and marialdb version information is like this.

enter image description here

Let me know if anyone here can help me for same

Thanks!

>Solution :

This is a PhpMyAdmin bug. You need to upgrade to 5.5.0 to get the fix.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading