Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Petter120
Helper I
Helper I

Parameter in MYSQL query is not working

Hi i have a MySQL query im trying to run from Power query editor and it usually work but this query has a parameter inside of it and its givning me an error:

SET @row_index := 1;

SET @row_index := -1;
SELECT DATUM,"FM" As Skift, Format(stddev(Duration),2) As STDEV, Format(avg(Duration),2) As Arimetric_Mean, (SELECT Format(AVG(subq.Duration),2) as median_value
FROM  (
    SELECT  s.DATUM, @row_index:=@row_index + 1 AS row_index, s.Duration
    FROM production_db.cykeltider_t as s
    WHERE s.LASTTID >= '2022-09-01 05:45:00' and s.LASTTID < '2022-09-01 15:00:00'  and s.OMRADE = "1022-08" 
    ORDER BY s.Duration) AS subq
  WHERE subq.row_index 
  IN (FLOOR(@row_index / 2) , CEIL(@row_index / 2))) as T

FROM production_db.cykeltider_t
WHERE LASTTID >= '2022-09-01 05:45:00' and LASTTID < '2022-09-01 15:00:00'  and OMRADE = "1022-08";

 

I am getting this error, an anyone assist me with this?

Petter120_0-1665616309143.png

DataSource.Error: ODBC: ERROR [42000] [MySQL][ODBC 8.0(w) Driver][mysqld-8.0.28]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 DATUM,"FM" As Skift, Duration, Duration
FROM production_db.cykeltider_t, ' at line 2
Information:
DataSourceKind=Odbc
DataSourcePath=dsn=MY_SQL
OdbcErrors=[Table]

 

Best regards 
Petter

3 REPLIES 3
ImkeF
Super User
Super User

Sorry, no further ideas from me here.

 

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

ImkeF
Super User
Super User

Hi @Petter120 ,
could this actually be an issue with the double quotes? They act as escape signs in Power Query.
Couldn't you replace them with single quotes in your SQL-statement?

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

No that didnt work

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

Top Solution Authors
Top Kudoed Authors