61a lecture 34 announcements integer examples continued a
play

61A Lecture 34 Announcements Integer Examples (continued) A Very - PowerPoint PPT Presentation

61A Lecture 34 Announcements Integer Examples (continued) A Very Interesting Number The mathematician G. H. Hardy once remarked to the mathematician Srinivasa Ramanujan... 4 A Very Interesting Number The mathematician G. H. Hardy once


  1. 61A Lecture 34

  2. Announcements

  3. Integer Examples (continued)

  4. A Very Interesting Number The mathematician G. H. Hardy once remarked to the mathematician Srinivasa Ramanujan... 4

  5. A Very Interesting Number The mathematician G. H. Hardy once remarked to the mathematician Srinivasa Ramanujan... (Demo) 4

  6. Aggregation

  7. Aggregate Functions 6

  8. Aggregate Functions So far, all SQL expressions have referred to the values in a single row at a time 6

  9. Aggregate Functions So far, all SQL expressions have referred to the values in a single row at a time [expression] as [name], [expression] as [name], ... select [columns] from [table] where [expression] order by [expression]; 6

  10. Aggregate Functions So far, all SQL expressions have referred to the values in a single row at a time [expression] as [name], [expression] as [name], ... select [columns] from [table] where [expression] order by [expression]; An aggregate function in the [columns] clause computes a value from a group of rows 6

  11. Aggregate Functions So far, all SQL expressions have referred to the values in a single row at a time [expression] as [name], [expression] as [name], ... select [columns] from [table] where [expression] order by [expression]; An aggregate function in the [columns] clause computes a value from a group of rows create table animals as 6

  12. Aggregate Functions So far, all SQL expressions have referred to the values in a single row at a time [expression] as [name], [expression] as [name], ... select [columns] from [table] where [expression] order by [expression]; An aggregate function in the [columns] clause computes a value from a group of rows create table animals as select "dog" as kind, 4 as legs, 20 as weight union 6

  13. Aggregate Functions So far, all SQL expressions have referred to the values in a single row at a time [expression] as [name], [expression] as [name], ... select [columns] from [table] where [expression] order by [expression]; An aggregate function in the [columns] clause computes a value from a group of rows create table animals as select "dog" as kind, 4 as legs, 20 as weight union select "cat" , 4 , 10 union 6

  14. Aggregate Functions So far, all SQL expressions have referred to the values in a single row at a time [expression] as [name], [expression] as [name], ... select [columns] from [table] where [expression] order by [expression]; An aggregate function in the [columns] clause computes a value from a group of rows create table animals as select "dog" as kind, 4 as legs, 20 as weight union select "cat" , 4 , 10 union select "ferret" , 4 , 10 union 6

  15. Aggregate Functions So far, all SQL expressions have referred to the values in a single row at a time [expression] as [name], [expression] as [name], ... select [columns] from [table] where [expression] order by [expression]; An aggregate function in the [columns] clause computes a value from a group of rows create table animals as select "dog" as kind, 4 as legs, 20 as weight union select "cat" , 4 , 10 union select "ferret" , 4 , 10 union select "parrot" , 2 , 6 union 6

  16. Aggregate Functions So far, all SQL expressions have referred to the values in a single row at a time [expression] as [name], [expression] as [name], ... select [columns] from [table] where [expression] order by [expression]; An aggregate function in the [columns] clause computes a value from a group of rows create table animals as select "dog" as kind, 4 as legs, 20 as weight union select "cat" , 4 , 10 union select "ferret" , 4 , 10 union select "parrot" , 2 , 6 union select "penguin" , 2 , 10 union 6

  17. Aggregate Functions So far, all SQL expressions have referred to the values in a single row at a time [expression] as [name], [expression] as [name], ... select [columns] from [table] where [expression] order by [expression]; An aggregate function in the [columns] clause computes a value from a group of rows create table animals as select "dog" as kind, 4 as legs, 20 as weight union select "cat" , 4 , 10 union select "ferret" , 4 , 10 union select "parrot" , 2 , 6 union select "penguin" , 2 , 10 union select "t-rex" , 2 , 12000; 6

  18. Aggregate Functions So far, all SQL expressions have referred to the values in a single row at a time [expression] as [name], [expression] as [name], ... select [columns] from [table] where [expression] order by [expression]; An aggregate function in the [columns] clause computes a value from a group of rows animals: create table animals as select "dog" as kind, 4 as legs, 20 as weight union kind legs weight select "cat" , 4 , 10 union dog 4 20 select "ferret" , 4 , 10 union cat 4 10 select "parrot" , 2 , 6 union ferret 4 10 select "penguin" , 2 , 10 union select "t-rex" , 2 , 12000; parrot 2 6 penguin 2 10 t-rex 2 12000 6

  19. Aggregate Functions So far, all SQL expressions have referred to the values in a single row at a time [expression] as [name], [expression] as [name], ... select [columns] from [table] where [expression] order by [expression]; An aggregate function in the [columns] clause computes a value from a group of rows animals: create table animals as select "dog" as kind, 4 as legs, 20 as weight union kind legs weight select "cat" , 4 , 10 union dog 4 20 select "ferret" , 4 , 10 union cat 4 10 select "parrot" , 2 , 6 union ferret 4 10 select "penguin" , 2 , 10 union select "t-rex" , 2 , 12000; parrot 2 6 penguin 2 10 select max(legs) from animals; t-rex 2 12000 6

  20. Aggregate Functions So far, all SQL expressions have referred to the values in a single row at a time [expression] as [name], [expression] as [name], ... select [columns] from [table] where [expression] order by [expression]; An aggregate function in the [columns] clause computes a value from a group of rows animals: create table animals as select "dog" as kind, 4 as legs, 20 as weight union kind legs weight select "cat" , 4 , 10 union dog 4 20 select "ferret" , 4 , 10 union cat 4 10 select "parrot" , 2 , 6 union ferret 4 10 select "penguin" , 2 , 10 union select "t-rex" , 2 , 12000; parrot 2 6 penguin 2 10 select max(legs) from animals; t-rex 2 12000 max(legs) 4 6

  21. Aggregate Functions So far, all SQL expressions have referred to the values in a single row at a time [expression] as [name], [expression] as [name], ... select [columns] from [table] where [expression] order by [expression]; An aggregate function in the [columns] clause computes a value from a group of rows animals: create table animals as select "dog" as kind, 4 as legs, 20 as weight union kind legs weight select "cat" , 4 , 10 union dog 4 20 select "ferret" , 4 , 10 union cat 4 10 select "parrot" , 2 , 6 union ferret 4 10 select "penguin" , 2 , 10 union select "t-rex" , 2 , 12000; parrot 2 6 penguin 2 10 select max(legs) from animals; t-rex 2 12000 max(legs) (Demo) 4 6

  22. Mixing Aggregate Functions and Single Values animals: create table animals as select "dog" as kind, 4 as legs, 20 as weight union kind legs weight select "cat" , 4 , 10 union dog 4 20 select "ferret" , 4 , 10 union cat 4 10 select "parrot" , 2 , 6 union ferret 4 10 select "penguin" , 2 , 10 union select "t-rex" , 2 , 12000; parrot 2 6 penguin 2 10 t-rex 2 12000 7

  23. Mixing Aggregate Functions and Single Values An aggregate function also selects a row in the table, which may be meaningful animals: create table animals as select "dog" as kind, 4 as legs, 20 as weight union kind legs weight select "cat" , 4 , 10 union dog 4 20 select "ferret" , 4 , 10 union cat 4 10 select "parrot" , 2 , 6 union ferret 4 10 select "penguin" , 2 , 10 union select "t-rex" , 2 , 12000; parrot 2 6 penguin 2 10 t-rex 2 12000 7

Recommend


More recommend