I am using mysql 8.0.21. I am trying to execute this statement:
WITH t
AS (SELECT h.store_hsh,
Avg(s.sales) AS SALES_AVG,
Avg(s.customers) AS CSTMR_AVG
FROM sat_day_facts s
INNER JOIN link_day l
ON s.link_day_hsh = l.link_day_hsh
INNER JOIN hub_store h
ON h.store_hsh = l.store_hsh
GROUP BY h.store_hsh)
SELECT t.store_hsh,
Now() AS LOAD_DATETIME,
Now() AS LOAD_END_DATETIME,
t.sales_avg,
t.cstmr_avg,
(SELECT 1 + Count(*)
FROM t t1
WHERE t1.sales_avg > t.sales_avg) AS SALES_RANK;
but I keep having this error
ProgrammingError: 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WITH t as (select h.STORE_HSH, AVG(s.SALES) as SALES_AVG , AVG(s.CUSTOMERS) as' at line 1
I checked the manual of SQL but still don't understand what is going wrong.
Does anyone could help?
Related
I tried to execute this query in ubuntu / mysql:
SELECT t1.SCHEMA_NAME, CONCAT(ROUND(BUCKET_QUANTILE*100,2),"% under ",
BUCKET_TIMER_HIGH/1000000000," milliseconds") fact,
LEFT(QUERY_SAMPLE_TEXT,64) as QUERY_SAMPLE, t1.DIGEST,
COUNT(t1.DIGEST)
OVER(PARTITION BY t1.DIGEST) as TOT
FROM events_statements_histogram_by_digest t1
JOIN events_statements_summary_by_digest t2
ON t2.DIGEST = t1.DIGEST
WHERE COUNT_BUCKET >1
ORDER BY t1.DIGEST, BUCKET_TIMER_HIGH DESC
LIMIT 10\G
and the result :
ERROR 1064 (42000): You have an error in your SQL syntax;
check the manual that corresponds to your MySQL server version
for the right syntax to use near
'(PARTITION BY t1.DIGEST) as TOT FROM events_statements_histogram_by_digest t1 JO'
at line 1
I have not found a way to correct that query. Please help. thanks.
When using mysql to run this query,
select country_code, Avg(freq) as frequency
from
(
select t1.country_code, t1.freq
from avg_call country_code_final t1
union all
select t2.country_code, t2.freq
from calls_at_one xx_country_code_frequency t2
)
group by country_code;
I received an
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '
select t1.country_code, t1.freq
from avg_call country_code_final t1
union all
select t2.country_code, t2.freq
from calls_at_one xx_country_code_frequency t2
)
group by country_code;'`
I tried running this on WebSQL it work.
I just wanted to switch from sqlite3 to using MySQL but I get errors in this query:
SELECT
metapp_notif.id,
name,
age,
place,
note,
metapp_notif.lat,
metapp_notif.longt,
haslatlong,
dati,
ntype,
grpm_id,
image,
send_id,
pro.latitude,
pro.longtitude,
metapp_notif.dati,
metapp_notif.activity
FROM (metapp_notif
join (metapp_profil
join metapp_userlocation
ON metapp_profil.user_id = metapp_userlocation.user_id) AS pro
ON metapp_notif.send_id = pro.user_id)
WHERE metapp_notif.rec_id =% d;
I'm getting this error:
ERROR 1064 (42000): You have an error in your SQL syntax; check the
manual that corresponds to your MySQL server version for the right
syntax to use near 'pro on metapp_notif.send_id=pro.user_id) where
metapp_notif.rec_id=2' at line 1
I was searching for differences between sqlite3 and mysql but can't figure out what is wrong.
Thanks in advance!
Try this syntax in Mysql
SELECT metapp_notif.id,
name,
age,
place,
note,
metapp_notif.lat,
metapp_notif.longt,
haslatlong,
dati,
ntype,
grpm_id,
image,
send_id,
latitude,
longtitude,
metapp_notif.dati,
metapp_notif.activity
FROM metapp_profil
join metapp_notif
ON metapp_notif.send_id = metapp_profil.user_id
join metapp_userlocation
ON metapp_profil.user_id = metapp_userlocation.user_id
WHERE metapp_notif.rec_id like '% d'; -- Not sure what you are trying to do here
Why do I always get a syntax error on the following inner join:
SELECT 'myapp_instagram_shop'.id
FROM 'myapp_instagram_shop'
INNER JOIN 'myapp_instagram_shop_picture'
ON 'myapp_instagram_shop'.id = 'myapp_instagram_shop_picture'.shop_id;
Error is:
1064 - You have an error in your SQL syntax; check the manual that corresponds to
your MySQL server version for the right syntax to use near ''myapp_instagram_shop'
INNER JOIN 'myapp_instagram_shop_picture' ON 'sh' at line 1
try
SELECT myapp_instagram_shop.id FROM myapp_instagram_shop INNER JOIN myapp_instagram_shop_picture ON myapp_instagram_shop.id = myapp_instagram_shop_picture.shop_id;
I have this query:
DELETE FROM amx_admins_servers, amx_amxadmins
WHERE
amx_admins_servers.admin_id = (SELECT id FROM amx_amxadmins WHERE username='kokoz')
AND amx_amxadmins.username = 'kokoz'
but didnt work.
I get sql error:
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use
near 'WHERE amx_admins_servers.admin_id = (SELECT id FROM
amx_amxadmins WHERE username' at line 2
where is the problem ?
Looks like you want to delete an admin user and all its entries in the server table. Use
DELETE a, s
FROM amx_amxadmins a
inner join amx_admins_servers s on a.id = s.admin_id
WHERE a.username='kokoz'