ORDER BY is not working properly in MySQL -


the following select query want order by transtype = 'i' , after transdate in ascending order. through query can transtype = 'i' record after not displays in proper sequence.

  select tranjectionid,date_format(transdate,'%d-%m-%y') transdate,motiamount,                              transtype,tranjection.partyid,item.itemname,gwt,loss,netwet,                               party.partyname,melting,westage,finewet,rhodium,amount,bhav                            tranjection,party,item                        party.partyid =  tranjection.partyid                        , item.itemid =  tranjection.itemid                          , tranjection.partyid = ".$partyid."                         order  (transtype = 'r') desc,                                    transdate 

while doing order may as

order  case    when transtype = 'i' 0 else 1  end, transdate; 

Comments

Popular posts from this blog

c++ - Delete matches in OpenCV (Keypoints and descriptors) -

java - Could not locate OpenAL library -

sorting - opencl Bitonic sort with 64 bits keys -