SQL .

SQL Max

SQL Max() Example One - Characters

Q: What Bill Murray movie has the last title alphabetically?
   
 Select Max(Film_Title)
   From Thespian_Film_Table
  Where Thespian_Last_Name  equals "Murray"
    and Thespian_First_Name equals "Bill";
   
 Where the Buffalo Roam
Max and Min can be used to find the row with the greatest or smallest value characters. Max and Min can also find the row with the largest or smallest numerical value.

SQL Max() Example Two - Numerics

Q: What was the latest movie Bill Murray of Caddyshack, Ghostbusters, or Rushmore?
   
 Select Max(Film_Year)
   From Film_Table
  Where Film_Title in ("Caddyshack", "Ghostbusters", "Rushmore");
   
 1998

Bonus SQL Max() Example Three - Numerics With a Subselect

1998? How is that helpful to me? I asked "what was the latest movie Bill Murray made of Caddyshack, Ghostbusters, or Rushmore?"
   
 Select Film_Title
   From Film_Table
  Where Film_Title in ("Caddyshack", Ghostbusters", "Rushmore")
    and Film_Year in            
         (Select Max(Film_Year)
            From Film_Table
           Where Film_Title in ("Caddyshack",
                                "Ghostbusters", 
                                "Rushmore") );
   
 Rushmore
Comments Comments are left by visitors to FluffyCat.com and may or may not be accurate.
Comment by shibu on 2008-10-17 Rate this Comment

Can u say how to find the second max()

 
Sign in to comment on SQL Max.