SQL WHERE BETWEEN Clause

The SQL WHERE BETWEEN syntax

The general syntax is:

  1. SELECT columnnames
  2. FROM tablename
  3. WHERE columnname BETWEEN value1 AND value2

 


 

SQL WHERE BETWEEN Examples

Problem: List all products between $10 and $20

  1. SELECT Id, ProductName, UnitPrice
  2. FROM Product
  3. WHERE UnitPrice BETWEEN 10 AND 20
  4. ORDER BY UnitPrice

Results: 29 records.

Id ProductName UnitPrice
3 Aniseed Syrup 10.00
21 Sir Rodney’s Scones 10.00
74 Longlife Tofu 10.00
46 Spegesild 12.00
31 Gorgonzola Telino 12.50

 


Problem: List all products not between $10 and $100 sorted by price.

  1. SELECT Id, ProductName, UnitPrice
  2. FROM Product
  3. WHERE UnitPrice NOT BETWEEN 5 AND 100
  4. ORDER BY UnitPrice

Results: 4 records.

Id ProductName UnitPrice
33 Geitost 2.50
24 Guaraná Fantástica 4.50
29 Thüringer Rostbratwurst 123.79
38 Côte de Blaye 263.50

Problem: Get the number of orders and amount sold between Jan 1, 2013 and Jan 31, 2013.

  1. SELECT COUNT(Id), SUM(TotalAmount)
  2. FROM [Order]
  3. WHERE OrderDate BETWEEN ‘1/1/2013’ AND ‘1/31/2013’

Results:

Count TotalAmount
33 66692.80

Comments (104)

  1. Pingback: w88 lite

  2. Pingback: Pinball Machines for Sale

  3. Pingback: Facebook Marketing

  4. Pingback: nằm mơ thấy núi lửa

  5. Pingback: 안전놀이터

  6. Pingback: DevOps strategy

  7. Pingback: mơ thấy kim cương

  8. Pingback: mơ đánh vợ

  9. Pingback: mơ gãy răng cửa

  10. Pingback: Stiiizy starter kit

  11. Pingback: tính cách cung bảo bình nữ

  12. Pingback: mơ thấy đi chùa

  13. Pingback: Harold Jahn Canada

  14. Pingback: tai game dua ngua

  15. Pingback: cvv dumps

  16. Pingback: mo thay di chua

  17. Pingback: Cornhole Shop

  18. Pingback: nằm mơ thấy tóc bạc

  19. Pingback: mơ thấy con trâu đánh đề con gì

  20. Pingback: nằm mơ thấy bướm

  21. Pingback: lions cornole board game

  22. Pingback: ตู้แปลภาษา

  23. Pingback: mơ thấy con ngựa

  24. Pingback: mơ thấy nhà xí

  25. Pingback: mo thay be gai

  26. Pingback: mơ thấy gái đẹp đánh con gì

  27. Pingback: Digital Transformation

  28. Pingback: Cooler Master Sentinel Advance manuals

  29. Pingback: https://boccadentalspa.com

  30. Pingback: windshield replacement Springfield IL

  31. Pingback: เซ็กซี่บาคาร่า

  32. Pingback: syarat cpns kemendikbud 2022

  33. Pingback: dumps shop

  34. 응답

    Have you ever thought about including a little
    bit more than just your articles? I mean, what you say is important and all.
    However think about if you added some great graphics or video clips to give your posts more, “pop”!
    Your content is excellent but with pics and video clips,
    this website could definitely be one of the very best in its niche.
    Excellent blog!

  35. Pingback: โกง

  36. Pingback: relx infinity

  37. Pingback: 안전놀이터

  38. Pingback: Amazon

  39. 응답

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

  40. 응답

    Ahaa, its good conversation regarding this piece of
    writing at this place at this website, I have read all that, so at this time me also commenting here.

    0mniartist asmr

  41. Pingback: cold war cheat

  42. 응답

    Thanks for ones marvelous posting! I certainly enjoyed reading it,
    you can be a great author.I will be sure to
    bookmark your blog and will come back later on. I want to encourage you
    to definitely continue your great writing, have a nice weekend!

  43. 응답

    Hello! I just wanted to ask if you ever have any trouble with hackers?
    My last blog (wordpress) was hacked and I ended up losing
    many months of hard work due to no backup. Do
    you have any methods to protect against hackers?

  44. 응답

    Fantastic goods from you, man. I’ve understand your stuff
    previous to and you’re just too magnificent. I really like what you have acquired here, really like what you are stating and the way in which you say it.
    You make it enjoyable and you still take care of to keep it sensible.

    I can’t wait to read much more from you. This is really a wonderful web site.

  45. 응답

    Hi there everybody, here every person is sharing these kinds of
    knowledge, therefore it’s good to read this website, and I used to visit this blog
    all the time.

  46. 응답

    Hi to every body, it’s my first go to see of this webpage;
    this weblog includes awesome and really excellent stuff designed for
    visitors.

  47. 응답

    At this time I am going away to do my breakfast, after having my breakfast
    coming again to read more news.

  48. 응답

    When some one searches for his vital thing, so he/she wants
    to be available that in detail, thus that thing is maintained over
    here.

  49. 응답

    scoliosis
    always i used to read smaller articles or reviews that as well
    clear their motive, and that is also happening with this post which I am reading at this place.
    scoliosis

  50. 응답

    scoliosis
    I’ve been exploring for a little for any high-quality articles or weblog posts
    in this sort of area . Exploring in Yahoo I eventually
    stumbled upon this website. Reading this information So i am happy to express that I
    have an incredibly just right uncanny feeling I discovered exactly what I needed.
    I such a lot certainly will make certain to don?t overlook this website and provides it a look on a constant basis.
    scoliosis

  51. 응답

    scoliosis
    I’ve been surfing online more than 3 hours today, yet I
    never found any interesting article like yours. It’s pretty
    worth enough for me. Personally, if all web owners and bloggers
    made good content as you did, the net will be much more useful than ever before.
    scoliosis

  52. 응답

    Hi, I do believe this is a great web site. I stumbledupon it 😉 I am going to
    revisit yet again since i have book marked it. Money and freedom is the greatest way to change,
    may you be rich and continue to help others.

  53. 응답

    Great post. I used to be checking constantly
    this weblog and I’m inspired! Very helpful info particularly the
    closing phase 🙂 I deal with such info a lot. I used to be looking for this particular info for a very lengthy
    time. Thanks and good luck.

  54. 응답

    My spouse and I stumbled over here from a different page and thought I may as well check things out.
    I like what I see so now i’m following you. Look forward to looking at your web page
    repeatedly.

  55. 응답

    I blog frequently and I really thank you for your information. Your article has truly peaked my
    interest. I am going to take a note of your website and
    keep checking for new information about once
    per week. I opted in for your RSS feed too.

  56. 응답

    I’m no longer certain the place you’re getting your info,
    however great topic. I needs to spend some time studying much more
    or understanding more. Thank you for great info I was searching for
    this information for my mission.

  57. 응답

    Please let me know if you’re looking for a author for your site.
    You have some really good posts and I believe I would be a good asset.
    If you ever want to take some of the load off, I’d really like to write some material for your blog in exchange for a link back
    to mine. Please blast me an e-mail if interested. Many thanks!

  58. 응답

    My brother recommended I might like this website. He was entirely right.
    This submit actually made my day. You can not imagine
    simply how much time I had spent for this information! Thank you!

  59. 응답

    I have learn some good stuff here. Certainly value bookmarking
    for revisiting. I wonder how so much attempt you put to make this type of
    excellent informative site.

  60. 응답

    I must thank you for the efforts you’ve put in writing
    this website. I really hope to check out the same high-grade blog posts from
    you in the future as well. In fact, your creative writing abilities has
    encouraged me to get my own, personal blog now 😉

  61. 응답

    I know this if off topic but I’m looking into starting my own blog and was wondering what
    all is required to get setup? I’m assuming having a blog like
    yours would cost a pretty penny? I’m not very web savvy so I’m not 100% certain.
    Any tips or advice would be greatly appreciated.

    Thank you

  62. 응답

    Thank you for every other informative site. Where else may I am getting that
    type of info written in such an ideal approach? I’ve a challenge that I’m just now working on, and I have been on the
    look out for such information.

  63. 응답

    Hi, I do believe this is an excellent web site.

    I stumbledupon it 😉 I’m going to return once again since i
    have saved as a favorite it. Money and freedom is the best way to change, may you
    be rich and continue to help others.

  64. 응답

    I seriously love your blog.. Excellent colors & theme. Did you make
    this site yourself? Please reply back as I’m looking to create my
    own personal blog and want to learn where you got this from
    or what the theme is called. Cheers!

  65. 응답

    Greetings! Very useful advice in this particular article!
    It is the little changes that make the largest changes.
    Thanks a lot for sharing!

  66. 응답

    Hi, I do think this is a great website. I stumbledupon it ;
    ) I may revisit yet again since i have bookmarked it.
    Money and freedom is the greatest way to change, may you be rich and continue to help others.

  67. 응답

    Fine way of describing, and nice post to take facts concerning my presentation focus, which i am going
    to present in school.

  68. 응답

    Please let me know if you’re looking for a author for your weblog.
    You have some really good posts and I think I would be a good asset.
    If you ever want to take some of the load off, I’d really like to write some content for your blog
    in exchange for a link back to mine. Please blast me an email
    if interested. Kudos!

  69. 응답

    Definitely believe that which you said. Your favorite reason appeared to be on the web
    the simplest thing to be aware of. I say to
    you, I certainly get annoyed while people consider worries that they just do not
    know about. You managed to hit the nail upon the top as well as defined out the whole thing
    without having side-effects , people could take a signal.
    Will likely be back to get more. Thanks

  70. 응답

    I would like to thank you for the efforts you’ve put in penning this blog.
    I’m hoping to view the same high-grade blog posts from you
    in the future as well. In fact, your creative writing
    abilities has encouraged me to get my very own site now 😉

  71. 응답

    I am really impressed along with your writing skills and also with the layout in your weblog.

    Is that this a paid theme or did you customize it your self?
    Anyway stay up the excellent quality writing, it is uncommon to peer
    a nice weblog like this one today.. ps4 games https://bit.ly/3nkdKIi ps4 games

Leave a comment

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