Sorry for such a silly question.
below is the actual query:
SELECT DATE_FORMAT(b.maxtime, "%H:%i") as ts, b.max_value-b.min_value as
diff FROM (SELECT max(Anzahl) as max_value ,min(Anzahl) as min_value,
greatest(max(ts),min(ts)) as maxtime
FROM customer where ts rlike '^2017-06-06' and Typ="B4A"
GROUP BY hour(ts)) b;
And when I am passing it in executeQuery() method using java like below:
resultset =statement.executeQuery("SELECT DATE_FORMAT(b.maxtime,\"%H:%i\")
as ts, b.max_value-b.min_value as diff(SELECT max(Anzahl) as max_value
,min(Anzahl) as min_value, max(ts) as maxtime from customer where Typ = " +
"\"" + selected_value+"\""+" "+"and ts RLIKE"+"'^"+cal_value+"'"+ "GROUP BY
hour(ts))b");
I am getting error in SQL syntax. and Error is:
MySQL server version for the right syntax to use near
'(SELECT max(Anzahl) as max_value ,min(Anzahl) as min_value, max(ts) as maxtime f'at line 1
Can someone help me out to figure out the problem.