寻找练习来学习 SQL,使用 Northwind 数据库
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1065652/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Looking for exercises to learn SQL, using the Northwind database
提问by MedicineMan
I am trying to become more familiar with SQL by writing queries against the Northwind database.
我试图通过编写针对 Northwind 数据库的查询来更加熟悉 SQL。
I am looking for some exercises that would help me to learn SQL and features of SQL Server. It is important that the exercises have solutions, and in complicated cases, it would be great if there was an explanation for the query.
我正在寻找一些可以帮助我学习 SQL 和 SQL Server 功能的练习。重要的是练习有解决方案,在复杂的情况下,如果有对查询的解释就太好了。
Thanks for the answers so far but I still have not found whatI am looking for: Is there any free resource, available online, without registration, that I can find a list of these exercises?
感谢您的答案,但迄今为止我还没有发现什么我要找:有没有免费的资源,可在网上,无需注册,我能找到的这些演习的清单?
回答by Andrew-Dufresne
Wikibooks have few exercises: SQL Exercises
维基教科书很少有练习:SQL 练习
回答by jn29098
A few things to focus on that will exercise a lot of areas of SQL that you should know if you're going to be writing a lot of it:
如果您要编写大量 SQL,则需要关注的一些事项将涉及 SQL 的许多领域,您应该了解这些领域:
- Joins - INNER and OUTER (difference between LEFT and RIGHT JOIN)
- GROUP BY clause and working with aggregate functions such as SUM, MIN, MAX, etc..
- WHERE - for filtering records returned in a query
- Subqueries - Subqueriesand Correlated subqueries
- CASE, COALESCE, BETWEEN, CONVERT, CAST functions/statements
- 连接 - INNER 和 OUTER(LEFT 和 RIGHT JOIN 之间的区别)
- GROUP BY 子句并使用聚合函数,如 SUM、MIN、MAX 等。
- WHERE - 用于过滤查询中返回的记录
- 子查询 -子查询和相关子查询
- CASE、COALESCE、BETWEEN、CONVERT、CAST 函数/语句
Find a good data set and try to run some meaningful queries on it. Make sure you start with a problem you want to solve (i.e. what is the average order amount for people who live in WA in the Northwind database?).
找到一个好的数据集并尝试对其运行一些有意义的查询。确保您从要解决的问题开始(即 Northwind 数据库中居住在 WA 的人的平均订单金额是多少?)。
回答by caml
For a few simple problems/exercises: http://caml2010.wordpress.com/2010/06/12/northwind-exercise/
对于一些简单的问题/练习:http: //caml2010.wordpress.com/2010/06/12/northwind-exercise/
回答by SQLMenace
I would pick up Inside Microsoft SQL Server 2005: T-SQL Querying. This book is great and has exercises + answers
我会选择 Inside Microsoft SQL Server 2005: T-SQL Querying。这本书很棒,有练习+答案
I did an interview with the author a while back about this book, you can find that here: Interview With Itzik Ben-Gan Author Of Inside Microsoft SQL Server 2005: T-SQL Querying
不久前我就这本书采访了作者,您可以在这里找到:Interview With Itzik Ben-Gan Author Of Inside Microsoft SQL Server 2005: T-SQL Querying
回答by dotneter
If you have Reporting Services handy, or even Visual Studio, creating a few reports with aggregates, sums, counts etc will give you a little insight to how data can be used as information and really boost your SQL skills.
如果您手头有 Reporting Services,甚至是 Visual Studio,那么创建一些包含聚合、总和、计数等的报告将使您对如何将数据用作信息并真正提高您的 SQL 技能有一些了解。
I work in a telephony company where this goes on all the time. I have thisbook sitting on my desk which I have found really handy.
我在一家电话公司工作,这种情况一直在发生。我有这本书坐在我的办公桌上,我发现真的很方便。
Good luck! :)
祝你好运!:)
回答by Prashanth
The best way to learn in my opinion would be to work on a small hobby project.
在我看来,最好的学习方式是从事一个小型的爱好项目。
For instance, lets say you are interested in sports, pick up your favorite sport and envision how you would model the sport statistics in the most elegant way in the form of a SQL database. You would start thinking on the lines of how to pull data out of the db, update the data , so on and so forth.
例如,假设您对运动感兴趣,选择您最喜欢的运动,并设想如何以 SQL 数据库的形式以最优雅的方式对运动统计数据进行建模。您会开始思考如何从数据库中提取数据、更新数据等等。
Whenever you encounter an issue, you can go look at the reference books (The T-SQL querying book mentioned above is a very good one) and figure out the best way of doing it.
遇到问题,可以去看看参考书(上面提到的T-SQL查询书是很好的一本),找出最好的方法。
Toy examples,exercises are good. But in my opinion, unless you really face a problem and solve it on your own, the fundamentals don't stick into your head.
玩具示例,练习很好。但在我看来,除非你真的遇到问题并自己解决,否则基本面不会留在你的脑海中。
Articles like this http://www.sommarskog.se/dynamic_sql.htmlare also extremely helpful, since they provide insight into how, why and why not.
像http://www.sommarskog.se/dynamic_sql.html这样的文章也非常有帮助,因为它们提供了关于如何、为什么和为什么不的见解。
Also check out this link http://www.sql-server-performance.com/tips/related_web_links_p1.aspx
另请查看此链接http://www.sql-server-performance.com/tips/related_web_links_p1.aspx