Thursday 15 January 2015

mysql - Select values with latest date and group by an other column -


Myquery is getting the exact results I need, but when the data exceeds more than 1000 rows Select it Skilled

  Select ID, `UID`, Case Left_Leg & gt; If right_f then left_leg and left_leg and max_leg, select `date` from` date` (SELECT * FROM network t2 where id (choose ID (choose ID, uid, `date` (select from network order by 'UID', 'date' Descend) by TIDE group by UID) T3 and (left_log> = 500 or right_AGEGGDAG> = 500)) T1   

To get data from the network, want the latest dates for each UID Are & Gt; = 500 or right_legue & gt; = 500 wanted to take only two legs (left or right)

Maybe there may be some questions but core problem is with this code

  SELECT * from network t2 where id (select id by UID, UID, `date`) (select * UID by network order, 'date' given t4 group) T3)   

I want to improve this query because the data has increased so much that when the data increases. First of all, get the maximum date for each UID

  • Search Associate ID
  • Filter on the values ​​of the feet

    Example:

      SELECT id, UID, Greatest (left_geal, right_lag) as the Max_leg network from WHERE (UID, `date`) (selection by UID, Max (` date`) from the network group by UID) and (left_log> 500 or right_lag> 500)   

    Meditation Let that mean that if uid Area for a foot in the latest date & gt; 500, then results will not show up in the record. If you want the latest record with feet & gt; 500, the foot filter has to be taken in.

  • No comments:

    Post a Comment