How to count, sum, and average rows in SQL: Databases for Developers #6

Sdílet
Vložit
  • čas přidán 18. 04. 2017
  • Want to count how many rows your query returns?
    Or the number of orders per customer?
    Or find your fastest time to run races of 1k, 5k and 10k?
    You can answer all these questions in SQL using group by and aggregate functions. Watch this video to find out how!
    For a complete list of aggregate functions available in Oracle Database 12.2 g to: docs.oracle.com/database/122/S...
    Take the Databases for Developers FREE SQL course at devgym.oracle.com/pls/apex/dg...
    Need help with SQL? Ask us over on AskTOM: asktom.oracle.com
    Twitter: / chrisrsaxon
    Daily SQL Twitter tips: / sqldaily
    All Things SQL blog: blogs.oracle.com/sql/
    ============================
    The Magic of SQL with Chris Saxon
    Copyright © 2015 Oracle and/or its affiliates. Oracle is a registered trademark of Oracle and/or its affiliates. All rights reserved. Other names may be registered trademarks of their respective owners. Oracle disclaims any warranties or representations as to the accuracy or completeness of this recording, demonstration, and/or written materials (the “Materials”). The Materials are provided “as is” without any warranty of any kind, either express or implied, including without limitation warranties or merchantability, fitness for a particular purpose, and non-infringement.
  • Věda a technologie

Komentáře • 7

  • @dpu11
    @dpu11 Před 2 lety +2

    even though i have been working with SQL for more than 10 years...your funny way of presentation made me sit and watch this entire series on basic syntax..
    fantastic work sir.enjoyed it..

  • @LewisCardenas
    @LewisCardenas Před 7 lety

    Hi Chris, did you mean to say "Copy your group by clause into the select" or "copy your select columns into your group by statement"? Thanks.

    • @TheMagicofSQL
      @TheMagicofSQL  Před 7 lety

      All the (unaggregated) columns in your select must also be in your group by. Copying the columns you've selected that aren't in aggregate functions (sum, max, etc.) to the group by is an easy way to ensure this.
      Does this answer your question?

    • @LewisCardenas
      @LewisCardenas Před 7 lety

      Yes, it is just that in minute 3:56 I seem to hear you say "copy your group by clause into your select". Which I think is the reverse of what you wanting to say ;- )

    • @TheMagicofSQL
      @TheMagicofSQL  Před 7 lety +1

      Well you could approach it either way! I was thinking that you should make your select match group by (instead of the other way around).

    • @LewisCardenas
      @LewisCardenas Před 7 lety

      Thanks so much for the reply. Have great day.