Skip to content
Advertisement

Tag: mysql

Calculate rank of the users based on their max score using mysql

I have a table (called users) I need rank of users based on their score but I want rank on the bases of users max score. Expect result Answer You are looking for DENSE_RANK, But it supports mysql version higher than 8.0 use correlated-subquery to get max value by each User_id use two variables one to store rank another to

How to pass a php variable in WHERE clause of SELECT statement?

I have a php variable that I want to fetch another field in database using this variable in my where clause. My code: But this is printing me nothing. Don’t know where I am going wrong but any help would be appreciated. Answer You can either break the string and concatenate the variable with “..” Or you could wrap the

Mysql: GROUP BY custom date interval

Situation : a table where every minute X energy device saves its consumption. I have to calculate the daily consumption (at hourly intervals, 00 – 01 – 02 – 03 – 04 ….. 23) of a single device on a …

Advertisement