Help how to write a SQL statement

  Abstract: Help how to write a SQL statement 


  Abc 
  1 ww 100 
  2 ww 110 
  3 mm 90 
  4 mm 95 
  5 mm 120 
  6 yy 480 
  7 yy 70 
  8 tt 300 
  9 tt 150 


  Above is a form of a SQL statement, I hope that this has the following effects 

  Abc 
  6 yy 480 
  8 tt 300 
  5 mm 120 
  2 ww 110 

  B field is not repeated.    .    .    .    .    Thank you very simple sort C field 




  SELECT distinct (b) FROM table t order by tc; 



  Select * from table group by b order by c desc 



  Select * from table group by b order by c desc 
  The same as a floor, I do not authorized personal opinions 



  Not above the maximum, OK 
  Select * from (select a, b, max (c) as c from tab group by b) as t order by c desc; 



  Above this ok 



  Oh, too late! 



  Select max (a), b, max (c) from table group by b order by c desc 



  Select * from (select a, b, max (c) as c from tab group by b) as t order by c desc; 
  The OK 


  Thank you, but I am not solve my problem b field investigations are linked to the table, I do not test for the N line, the group by a single table on it.    . 

  ↑ Back 

Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • del.icio.us
  • Facebook
  • DotNetKicks
  • DZone
  • Netvouz
  • Propeller

Tags: , , , ,

Releated Java Articles

Comments

Leave a Reply