The SQL GROUP BY syntax

The general syntax is:

  1. SELECT columnnames
  2. FROM tablename
  3. WHERE condition
  4. GROUP BY columnnames

The general syntax with ORDER BY is:

  1. SELECT columnnames
  2. FROM tablename
  3. WHERE condition
  4. GROUP BY columnnames
  5. ORDER BY columnnames




Problem: List the number of customers in each country

  1. SELECT COUNT(Id), Country
  2. FROM Customer
  3. GROUP BY Country

Results: 21 records.

Count Country
3 Argentina
2 Austria
2 Belgium
9 Brazil
3 Canada


Problem: List the number of customers in each country sorted high to low

  1. SELECT COUNT(Id), Country
  2. FROM Customer
  3. GROUP BY Country

Results: 21 records.

Count Country
13 USA
11 France
11 Germany
9 Brazil
7 UK


Problem: List the total amount ordered for each customer

  1. SELECT SUM(O.TotalPrice), C.FirstName, C.LastName
  2. FROM [Order] O JOIN Customer C
  3. ON O.CustomerId = C.Id
  4. GROUP BY C.FirstName, C.LastName
  5. ORDER BY SUM(O.TotalPrice) DESC

This query uses a JOIN with Customer to obtain customer names
Results: 89 records.

Sum FirstName LastName
117483.39 Horst Kloss
115673.39 Jose Pavarotti
113236.68 Roland Mendel
57317.39 Patricia McKenna
52245.90 Paula Wilson
34101.15 Mario Pontes
32555.55 Maria Larsson

Comments (95)

  1. 응답

    I feel that is among the such a lot vital info for me.
    And i am satisfied studying your article. But want to commentary on few common issues, The site style is perfect, the articles is
    truly great : D. Good job, cheers

  2. 응답

    Cbd oil that works 2020
    I have been browsing on-line greater than 3 hours these days, yet I never
    discovered any fascinating article like yours. It’s
    beautiful price sufficient for me. In my view, if
    all web owners and bloggers made excellent content material as you probably did,
    the web might be a lot more useful than ever before. best rated cbd oil http://j.mp/3drY6lE cbd oil
    that works 2020 http://j.mp/3drY6lE

  3. 응답

    After checking out a number of the articles on your blog, I honestly appreciate your way of writing a blog.

    I saved as a favorite it to my bookmark webpage list and will be checking back in the near
    future. Please check out my web site too and let me know your opinion.

  4. 응답

    Hi, I believe your web site could possibly be having browser
    compatibility issues. Whenever I look at your web site
    in Safari, it looks fine but when opening in Internet Explorer, it’s got some overlapping issues.
    I just wanted to provide you with a quick heads up!
    Aside from that, wonderful site! adreamoftrains web
    hosting reviews

  5. Pingback: b2b

  6. Pingback: situs bola

  7. 응답

    You complete a number of earn points near. I did a explore resting on the topic and found mainly people will support with your website.

  8. Pingback: replica rolex sea dweller

  9. Pingback: 홀덤사이트

  10. Pingback: Köp Lyrica online

  11. Pingback: health insurance

  12. Pingback: Sexual Revolution (Roger Waters song)

  13. Pingback: UNICORN

  14. Pingback: fake rolex

  15. Pingback: buy morphine online

  16. Pingback: World Market URL

  17. Pingback: Köp smärtpiller i Sverige

  18. Pingback: cabins for sale in payson az

  19. Pingback: sagaming

  20. Pingback: happymod.net.br

  21. Pingback: hackear whatsapp gratis

  22. 샌즈카지노


    One of the best things about poker is that it’s a game available to everyone. Regardless of your age, profession, or sex, you can learn to play poker and enjoy it online and live without any real obstacles. 샌즈카지노

  23. 정선카지노


    Given the fact there is nothing in the game rules to discriminate against female players, it’s only natural to wonder why there aren’t more women in poker? 정선카지노

  24. 라이브카지노


    Poker started as a male-dominated activity, and during the early days of the game, it was played almost exclusively by men. Rare female players to hit the felt were definitely going against the social norms of the period. 라이브카지노

  25. 샌즈카지노


    Of course, things have changed quite a bit over the decades, and we’re no longer living in the Wild West era, but the fact remains that the game started off on the wrong foot for the inclusion of women. 샌즈카지노

  26. 골프게임


    You’re won’t enjoy yourself, you don’t feel welcome, and at the end of a session, even if you end up winning, you’ll go home with a bitter taste in your mouth. 골프게임

  27. 비트코인


    Although there are no real studies to refer to in this regard, it’s safe to assume that many more women play the game online in a safe and protected environment. 비트코인

  28. 바카라


    Also, in most countries, men generally have access to more disposable income, and more importantly, they are probably more keen to put that money on the line in the game. 바카라

  29. 라이브카지노


    Women and men are widely considered to differ in terms of their emotions. Although things are never so clear-cut and this statement is pretty reductive, in general, men will find much more satisfaction in crushing their opponent’s soul than women. 라이브카지노

  30. Pingback: linh tiên song đằng tố

  31. Pingback: best site to buy dumps

  32. Pingback: microsoft exchange online plan 1

  33. Pingback: bulut depolama,bulut,yedekleme,ücretsiz bulut hizmeti,en iyi bulut şirketi,en iyi bulut firması,bulut depolama fiyatı,en ucuz bulut depolama,en iyi bulut depolama hangisi,en iyi bulut depolama,bulut arşivleme sistemi,online yedekleme,bulut yedekleme

  34. Pingback: exchange bulut mail

  35. Pingback: dell sunucu teknik servis

  36. Pingback: kurumsal sunucu servisi

  37. Pingback: it danışmanlık ücretleri

  38. Pingback: Hp Sunucu destek

  39. Pingback: microsoft exchange hosting fiyat

  40. Pingback: world market link

  41. Pingback: W88.tips

  42. 응답

    viagra free sample
    cvs pharmacy alcohol and viagra viagra shelf life canadian pharmacy reviews [url=https://cats-ads.com/user/profile/51479]www.canadian pharmacy[/url] cialis canada canada drugs online canada medications price for cialis in canada [url=https://musescore.com/user/39555010]best price cialis[/url]
    cialis pharmacy rx one cvs pharmacy costco pharmacy viagra canada online [url=https://bit.ly/37lLyf0+]my canadian pharcharmy online[/url]

  43. 응답

    buy cialis online canada pharmacy
    alcohol and viagra online cheap viagra viagra online canada pharmacy mail order viagra [url=http://allfreead.com/index.php?page=user&action=pub_profile&id=342288]cvs pharmacy[/url] buy viagra online uk over the counter viagra alternative viagra overnight shipping viagra-canada [url=https://saveyoursite.win/story.php?title=putting-a-stop-to-the-panic-handling-and-also-treating-anxiety-attack#discuss]canadian pharmacies viagra[/url]
    buy viagra online without script canada med canadian cialis online pharmacy cialis mexico pharmacy [url=https://ioby.org/user/birthanger79]mail order prescriptions from canada[/url]

  44. 응답

    online prescription
    canada pharmacy viagra canadian prescription drugstore viagra free trial generic viagra cheap [url=http://abroadsanjal.com/index.php?qa=user&qa_1=notifydetail37]viagra cost[/url] canada for viagra online drugs order cialis in canada real viagra [url=http://bbs.yx.dodjoy.com/home.php?mod=space&uid=412764]cheapest viagra prices[/url]
    canadian pharmacies without a prescription herbal viagra reviews buy generic cialis canadian pharmacy viagra online sales [url=https://myemotion.faith/wiki/Take_advantage_of_Your_Charm_Routine_With_These_Tips]alternatives to viagra[/url]

  45. 응답

    pills from canada
    canadianpharmacymeds.com medications.com how to take viagra ?viagra canada [url=https://git.skewed.de/atmedward90]viagra mail order[/url] cialis pharmacy tadalafil in canada northwestpharmacy.com canada no prescription pharmacy [url=https://www.hostingendomeinen.nl/support/profile.php?section=personal&id=460166]canadian online drugstore[/url]
    free viagra sample pack canadian pharmacy viagra online overseas pharmacy viagra pill [url=https://easybookmark.win/story.php?title=exactly-how-to-order-as-well-as-usage-your-generic-cialis-online-without-prescription-7#discuss]viagra from canadian pharmacy[/url]

  46. 응답

    viagra from india
    viagra online canada pharmacy cialis in canadian pharmacies viagra without a doctor prescription best price on cialis [url=http://ffskybbsjp.azurewebsites.net/home.php?mod=space&uid=6830751]viagra safe[/url] meds canada cheap viagra uk canada medication canadian prescription [url=http://www.atlasroleplay.com/forum/profile/birthgarden38]pharmacy rx one 60 mg cialis[/url]
    northwestern pharmacy canada canadian-drugstore viagra substitute generic viagra india [url=https://www.sitiosperuanos.com/author/ringchange46/]www.canadianpharmacymeds.com[/url]

  47. Pingback: Throwaway Mail

  48. 응답

    Just want to say your article is as surprising. The clearness in your post is just spectacular
    and i can suppose you’re knowledgeable on this subject.

    Well together with your permission allow me to take hold of your feed to keep
    up to date with imminent post. Thanks 1,000,000 and
    please continue the gratifying work.

    Here is my web-site … 덤딒W2ifvrmbje.Kr

  49. 응답

    Link exchange is nothing else except it is simply placing the other person’s webpage link on your page at appropriate place and other
    person will also do same in favor of you.

    My homepage – 릴게임

  50. 응답

    It’s remarkable in support of me to have a web page, which is good designed for my experience.
    thanks admin

    Look at my page: Gwen

  51. 응답

    You can definitely see your enthusiasm within the work you write.
    The world hopes for even more passionate writers like you who are not afraid to say how they
    believe. Always follow your heart.

    Feel free to visit my web blog – Faith

  52. 응답

    If some one wants to be updated with hottest technologies therefore he must be pay a visit this web page and be up to date all the

    Here is my homepage – Kathrin

  53. 응답

    Superb blog! Do you have any recommendations for aspiring writers?
    I’m planning to start my own website soon but I’m a little lost on everything.
    Would you advise starting with a free platform like
    Wordpress or go for a paid option? There are so many options
    out there that I’m completely overwhelmed .. Any suggestions?

    Feel free to surf to my website … Darell

  54. 응답

    My family all the time say that I am wasting my time here
    at web, but I know I am getting knowledge all the time by reading such nice
    articles or reviews.

    Look into my site – 릴게임

  55. 응답

    An impressive share! I have just forwarded this onto a co-worker who was doing a little research on this.

    And he in fact bought me dinner simply because I discovered it
    for him… lol. So allow me to reword this….

    Thank YOU for the meal!! But yeah, thanks for spending the time to talk about this topic
    here on your web site.

    Also visit my web site: 릴게임

  56. 응답

    You have made some decent points there. I checked
    on the web for additional information about the issue and found most
    people will go along with your views on this web site.

    my homepage; 릴게임

  57. 응답

    Awesome blog! Is your theme custom made or did you download it from somewhere?
    A theme like yours with a few simple adjustements would
    really make my blog jump out. Please let me know where you got your design. Appreciate it

    Check out my web page … 릴게임

  58. 응답

    Howdy just wanted to give you a quick heads up. The text in your content seem to
    be running off the screen in Chrome. I’m not sure if this is a format issue
    or something to do with browser compatibility but I figured I’d post to
    let you know. The style and design look great though! Hope you
    get the issue fixed soon. Kudos

    my webpage: 릴게임

  59. 응답

    Hi! This post couldn’t be written any better! Reading through this post reminds me of my old room mate!
    He always kept talking about this. I will forward this article to him.
    Fairly certain he will have a good read. Thanks for sharing!

    Here is my webpage … 릴게임

  60. 응답

    It’s perfect time to make some plans for the future and it is time to be happy.
    I have read this post and if I could I desire to suggest you some interesting things
    or tips. Perhaps you could write next articles referring to this
    article. I wish to read more things about it!

    My site – 릴게임

  61. 응답

    Its like you learn my mind! You seem to grasp a
    lot about this, such as you wrote the e-book in it
    or something. I think that you just could do with
    a few p.c. to force the message house a bit,
    but other than that, that is fantastic blog. A great read.
    I’ll certainly be back.

    My page: 릴게임

  62. 응답

    Appreciating the hard work you put into your website and detailed information you offer.
    It’s nice to come across a blog every once in a while that isn’t
    the same unwanted rehashed information. Great read!
    I’ve saved your site and I’m including your RSS
    feeds to my Google account.

    Also visit my homepage :: 릴게임

  63. 응답

    I like the helpful information you provide in your articles.
    I’ll bookmark your weblog and check again here regularly.
    I’m quite sure I’ll learn many new stuff right here! Best of
    luck for the next!

    my blog mafiamind.Com

  64. 응답

    Good day! This post couldn’t be written any better! Reading this post
    reminds me of my previous room mate! He always kept talking about this.
    I will forward this post to him. Fairly certain he
    will have a good read. Thank you for sharing!

    My web-site :: 릴게임

  65. Embano


    порно , free xxx videos © 2017-2021 Порнушка на PROkazi.net. Все права защищены. Интервал: Мама опробовала хуй родного сына в ебле, устав трахаться с мужем инцест между матерью и сыном Отзывы читателей о книге Инцест, автор: Александр Пронин. Читайте комментарии и мнения людей о произведении. Русский сын вылизал пизду толстой мамы и выебал её до камшота на пузо порно , free xxx videos Брат выебал бухую сестру, пока она крепко спала порно , free xxx videos Брат выебал бухую сестру, пока она крепко спала Брат выебал бухую сестру, пока она крепко спала Брат уломал сестру на инцест и выебал У всех нас заложен генетический код инцестуального секса с кем то из родных, поэтому мы такие, поэтому, мы не можем и не хотим жить иначе, хотя мы ничем не отличаемся от остальных людей, разве только что мы более развиты во… А. Пронин А. Пронин Русский сын вылизал пизду толстой мамы и выебал её до камшота на пузо http://lms.shayanpervez.com/index.php/forum/profile/angelobratton4/ На сайте Порно365 нет обмана. Она девственница, зуб даём ВНИМАНИЕ! Вы используете устаревший браузер Internet Explorer Американка прижала горничную и воспользовалась ей Американка прижала горничную и воспользовалась ей 18-летнюю малышку заперли на ее первый порно кастинг © 2009—2021   Dt.pornk.topСмотреть порно видео бесплатно онлайн Наш сайт поддерживает cookies благодаря которым вы можете собирать личную коллекцию в закладке «Избранное». Настоятельно Вам рекомендуем выбрать и установить любой из современных браузеров. Это бесплатно и займет всего несколько минут. Зачем куда-то идти если дома есть все для группового порно с двойным проникновением Курящие кончают раком, Порно365 за ЗОЖ без анала 18-летнюю малышку заперли на ее первый порно кастинг Зачем куда-то идти если дома есть все для группового порно с двойным проникновением

Leave a comment

이메일 주소는 공개되지 않습니다.