SQL Alias

The SQL Alias syntax

The general syntax is:

  1. SELECT columnname AS aliasname
  2. FROM tablename aliasname
  3. WHERE condition

 


 

SQL Alias Examples

Problem: List total customers in each country.
Display results with easy to understand column headers.

  1. SELECT COUNT(C.Id) AS TotalCustomers, C.Country AS Nation
  2. FROM Customer C
  3. GROUP BY C.Country

TotalCustomers and Nation are column aliases.
The table alias (C) in this example is not particularly useful.
Results: 21 records

TotalCustomers Nation
3 Argentina
2 Austria
2 Belgium
9 Brazil
3 Canada

 


Problem: List the total amount ordered by customer
with easy to read column headers

  1. SELECT C.Id AS Identifier, C.LastName + ‘, ‘ + C.FirstName AS CustomerName,
  2. SUM(O.TotalAmount) AS TotalSpent
  3. FROM [Order] O JOIN Customer C ON O.CustomerId = C.Id
  4. GROUP BY C.Id, C.LastName + ‘, ‘ + C.FirstName
  5. ORDER BY TotalSpent DESC

The aliases significantly simplify writing the JOIN and ORDER BY clauses.
The C alias in C.Id helps identify the Customer Id rather then the Order Id.
Results: 89 records

Identifier CustomerName TotalSpent
63 Kloss, Horst 117483.39
71 Pavarotti, Jose 115673.39
20 Mendel, Roland 113236.68
37 McKenna, Patricia 57317.39
65 Wilson, Paula 52245.90

“SQL Alias”의 127개의 댓글

  1. 핑백: w88club

  2. 핑백: mơ thấy con cá đánh đề con gì

  3. 핑백: Pomsky puppies for sale near me

  4. 핑백: f1b labradoodles for sale

  5. 핑백: mơ thấy người cha đã mất

  6. 핑백: fun88

  7. 핑백: mo thay ran can

  8. 핑백: mơ thấy cứu người chết đuối

  9. 핑백: đeo kim cương có may mắn không

  10. 핑백: mơ cá chép đánh con gì

  11. 핑백: dơi bay vào nhà báo điềm gì

  12. 핑백: mơ đánh vợ

  13. 핑백: mơ thấy biển số xe danh con gi

  14. 핑백: mơ bị đòi nợ đánh con gì

  15. 핑백: mơ đi xe đạp đánh con gì

  16. 핑백: dwayne johnson

  17. 핑백: chiem bao thay di chua

  18. 핑백: Benefits of Intelligent Automation

  19. 핑백: mơ thấy bàn thờ tổ tiên

  20. 핑백: buy dumps online

  21. 핑백: นิยายจีนแปลไทย

  22. 핑백: safe black ops cold war cheats

  23. 핑백: bị bọ cạp cắn

  24. 핑백: mơ thấy đầu người

  25. 핑백: dumps track 2 shop

  26. 핑백: css image align

  27. 핑백: nằm mơ thấy hôn môi

  28. 핑백: nằm mơ thấy ốc đánh con gì

  29. Howdy! I know this is somewhat off topic but I was wondering which blog platform are
    you using for this site? I’m getting tired of WordPress because I’ve had problems with hackers and I’m looking at options for another platform.
    I would be fantastic if you could point me in the
    direction of a good platform.

  30. Pretty nice post. I just stumbled upon your blog and wished to say
    that I have truly enjoyed browsing your blog posts.
    In any case I will be subscribing to your rss feed and I hope you
    write again very soon!

  31. Thanks for any other informative site. Where else
    may I get that kind of information written in such a perfect way?

    I’ve a undertaking that I’m simply now running on, and I have been on the glance out for such info.

  32. Wow, amazing weblog format! How lengthy have you been running a blog for?

    you make blogging look easy. The entire look of your website is fantastic, let alone the content!

  33. 핑백: http://95.111.232.179/

  34. 핑백: ตู้แปลภาษา

  35. 핑백: mơ thấy mất của

  36. 핑백: con sau so may

  37. 핑백: nằm mơ thấy ngựa đánh số gì

  38. 핑백: những cách tỏ tình lãng mạn

  39. 핑백: sự tôn trọng trong tình yêu

  40. 핑백: mơ thấy bướm phụ nữ

  41. 핑백: http://95.111.232.180/

  42. I am extremely impressed with your writing skills and also with the layout on your blog. Is this a paid theme or did you customize it yourself? Either way keep up the excellent quality writing, it’s rare to see a great blog like this one these days.|

  43. You’re so interesting! I do not think I’ve read a single thing like this before. So good to discover another person with some genuine thoughts on this issue. Really.. many thanks for starting this up. This site is one thing that is needed on the internet, someone with a little originality!|

  44. Woah! I’m really loving the template/theme of this blog. It’s simple, yet effective. A lot of times it’s very difficult to get that “perfect balance” between user friendliness and visual appearance. I must say that you’ve done a very good job with this. In addition, the blog loads extremely fast for me on Chrome. Outstanding Blog!|

  45. I think this is one of the most vital information for me. And i am glad reading your article. But wanna remark on few general things, The site style is perfect, the articles is really great : D. Good job, cheers|

  46. What i do not realize is in reality how you are now not actually much more smartly-preferred than you might be now. You’re very intelligent. You recognize therefore considerably with regards to this matter, produced me for my part imagine it from a lot of numerous angles. Its like men and women don’t seem to be involved unless it’s one thing to accomplish with Lady gaga! Your personal stuffs outstanding. At all times maintain it up!|

  47. Thank you for any other informative blog. The place else may just I get that type of info written in such a perfect manner? I’ve a project that I’m simply now operating on, and I’ve been on the look out for such information.|

  48. Hiya very nice website!! Guy .. Excellent .. Amazing .. I will bookmark your website and take the feeds additionally? I am satisfied to seek out a lot of helpful info here in the submit, we’d like work out more strategies on this regard, thanks for sharing. . . . . .|

  49. Excellent items from you, man. I’ve understand your stuff previous to and you are just extremely excellent. I actually like what you have obtained right here, certainly like what you’re saying and the best way during which you assert it. You make it enjoyable and you continue to take care of to stay it smart. I can not wait to learn much more from you. This is really a wonderful site.|

  50. It is the best time to make a few plans for the future and it is time to be happy. I’ve learn this publish and if I may I desire to recommend you few interesting things or tips. Perhaps you could write subsequent articles regarding this article. I desire to read more things about it!|

  51. Great work! This is the type of info that are supposed to be shared around the internet. Shame on Google for now not positioning this submit higher! Come on over and seek advice from my site . Thank you =)|

  52. Hmm is anyone else having problems with the pictures on this blog loading? I’m trying to find out if its a problem on my end or if it’s the blog. Any feedback would be greatly appreciated.|

  53. The other day, while I was at work, my sister stole my apple ipad and tested to see if it can survive a forty foot drop, just so she can be a youtube sensation. My apple ipad is now destroyed and she has 83 views. I know this is completely off topic but I had to share it with someone!|

  54. This is very fascinating, You are a very skilled blogger. I have joined your rss feed and sit up for in search of extra of your great post. Also, I’ve shared your website in my social networks|

  55. Very good blog you have here but I was curious about if you knew of any community forums that cover the same topics discussed in this article? I’d really like to be a part of online community where I can get comments from other experienced individuals that share the same interest. If you have any recommendations, please let me know. Kudos!|

  56. Pretty nice post. I just stumbled upon your weblog and wanted to say that I’ve truly
    enjoyed browsing your blog posts. In any case I’ll be subscribing to your
    feed and I hope you write again soon!

    Here is my webpage – Humboldts Best CBD Oil Reviews; www38.tok2.com,

  57. I have been surfing online more than three hours lately, but I by no means discovered
    any attention-grabbing article like yours.

    It’s lovely value enough for me. Personally, if all
    web owners and bloggers made just right content as you did, the web
    will be much more helpful than ever before. asmr 0mniartist

  58. You could certainly see your expertise in the article you write.
    The sector hopes for even more passionate writers like you
    who aren’t afraid to say how they believe. At all times go after your heart.
    asmr 0mniartist

  59. I leave a comment when I appreciate a article on a site or I
    have something to valuable to contribute to the discussion.
    Usually it’s caused by the fire displayed in the article I
    looked at. And on this post SQL Alias | 기록은 자산.
    I was excited enough to drop a thought 😉 I do have a few questions for you if you do not mind.
    Could it be simply me or does it look like like some
    of the remarks appear like written by brain dead visitors?
    😛 And, if you are writing at additional places, I would like to follow you.
    Would you make a list every one of all your shared pages like your linkedin profile, Facebook page
    or twitter feed?

    Also visit my blog … Creek Side CBD – http://www.lagrandefamiglia.it,

  60. Just want to say your article is as surprising. The clarity in your
    post is simply cool and i could assume you are an expert on this subject.

    Well with your permission allow me to grab your
    feed to keep up to date with forthcoming post. Thanks a
    million and please keep up the gratifying work.

    My site: Pure Remedy CBD Reviews; http://www.fotosombra.com.br,

  61. Howdy, i read your blog occasionally and i own a similar one and i
    was just wondering if you get a lot of spam remarks?
    If so how do you protect against it, any plugin or anything you can recommend?
    I get so much lately it’s driving me crazy so any assistance is very much appreciated.

  62. I’ll immediately clutch your rss as I can’t find your e-mail subscription link or e-newsletter service.

    Do you’ve any? Please let me realize so that I could subscribe.
    Thanks.

  63. It is appropriate 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 want to suggest you some interesting things or tips.
    Maybe you can write next articles referring to this article.
    I want to read even more things about it!

  64. I don’t even understand how I ended up right here, however I believed this submit used to be good.
    I do not realize who you might be but definitely you are going to a well-known blogger if you happen to
    aren’t already. Cheers!

  65. Hello very nice web site!! Guy .. Excellent .. Superb ..
    I’ll bookmark your blog and take the feeds additionally?
    I’m happy to find so many helpful information here
    in the put up, we’d like develop extra techniques in this
    regard, thank you for sharing. . . . . .

  66. This is the perfect webpage for anyone who wishes to understand this
    topic. You know a whole lot its almost hard to argue with you (not that
    I really would want to…HaHa). You certainly put a
    new spin on a topic that’s been written about for many years.
    Great stuff, just wonderful!

  67. Wow, wonderful weblog format! How long have you ever been running a blog for?
    you made blogging look easy. The overall
    glance of your web site is wonderful, as well as the
    content material!

  68. scoliosis
    It’s actually a cool and useful piece of info.
    I’m happy that you shared this helpful information with
    us. Please stay us informed like this. Thanks
    for sharing. scoliosis

  69. excellent post, very informative. I’m wondering why the
    opposite specialists of this sector do not notice this.
    You should continue your writing. I’m confident,
    you’ve a huge readers’ base already!

  70. Thank you a lot for sharing this with all of us you really understand what you are
    talking approximately! Bookmarked. Please also talk over
    with my website =). We may have a link exchange arrangement among us

  71. Good day very cool web site!! Man .. Beautiful .. Amazing ..
    I’ll bookmark your site and take the feeds additionally…I’m satisfied to find numerous useful info right here within the put up, we’d like work
    out more strategies on this regard, thank you for sharing.

    Look at my blog post: Bio Wellness CBD (http://www.fles.hlc.edu.tw)

  72. I don’t know whether it’s just me or if perhaps everyone else experiencing problems with your website.
    It appears like some of the written text within your content are running off the screen. Can somebody else please provide feedback
    and let me know if this is happening to them as well?

    This may be a issue with my internet browser because
    I’ve had this happen before. Appreciate it

  73. hey there and thank you for your information – I have definitely picked
    up something new from right here. I did however expertise several technical issues using this web site,
    since I experienced to reload the website many times previous to
    I could get it to load correctly. I had been wondering if your web hosting is OK?
    Not that I’m complaining, but sluggish loading instances
    times will sometimes affect your placement
    in google and can damage your high quality score if advertising and marketing with Adwords.
    Well I am adding this RSS to my email and could look out
    for much more of your respective fascinating content.

    Ensure that you update this again very soon.

  74. Write more, thats all I have to say. Literally, it seems as though you relied on the video to make your point.
    You obviously know what youre talking about, why throw away
    your intelligence on just posting videos to your weblog when you could be giving us something enlightening to read?

답글 남기기