3 Question about sql.

wwchar 2003-10-17 08:43:51
pet(name, owner, species, sex, checkups, birth, death)

the number of pets of each species that each owner has.
the number of birds each owner has.
the total number of checkups each owner has made with all their pets.
...全文
33 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
wwchar 2003-10-20
  • 打赏
  • 举报
回复
pet(name,owner,species)
name:宠物名字
owner:所有者
species:宠物种类(鸟,狗....)
每个owner所拥有的鸟的数量。
关键是有些owner没有鸟,查询出来表中就没有该owner名字,
现在想要的结果最好能把没有鸟的owner,拥有鸟的数量是0,而不是不在表中出现。
wwchar 2003-10-20
  • 打赏
  • 举报
回复
就是想让没有鸟的owner显示0,
用纯sql行不行
ustb 2003-10-19
  • 打赏
  • 举报
回复
看了半天没有看到问什么?
不过像这样经典的数据库问题相信随便找本书也能搞定了。
wwchar 2003-10-17
  • 打赏
  • 举报
回复
更新一下:有几个问题已经解决。
每个owner拥有的鸟的数目,我想让没有鸟的owner显示0,不知道有没有办法。
feel8 2003-10-17
  • 打赏
  • 举报
回复
实在看不懂,在装金山词霸。。
wwchar 2003-10-17
  • 打赏
  • 举报
回复
The number of distinct species of pet each owner has.
the number of birds each owner has.
the total number of checkups each owner has made with all their pets.
I had met Itzik Ben-Gan briefl y a couple of times and knew of his reputation, so I was looking forward to his afternoon session on avoiding cursors in SQL programming at PASS. I was lucky to get there early, as the large room fi lled up quickly. Itzik took a couple of SQL programming problems and diced them up in the most skillful and entertaining way, showing the elegance and effi ciency of set-oriented thinking. The audience loved it—and so did I, except I had a different angle. Having worked on the internals of SQL Server, I could see Itzik touch the product nerves in his demos, and I admired how he turned features into beautiful solutions. After the session, I asked one of the attendees what had been his main takeaway, curious about which of the many techniques would have stood out for him. He looked at me, mildly surprised, and just said, “The man is a genius!” That pretty much sums it up. This question of cursors is more fundamental than it may appear at fi rst. It points to a deep dichotomy of tremendous practical importance. Most of us were taught to program by chopping up a task into smaller steps that, when executed in sequence, perform a desired computation. But if you approach SQL programming this way, you will get only mediocre results. Your code will be much larger and harder to maintain. It will be less effi cient, less fl exible, and less tunable. Using SQL effectively is not about an incremental extension of your procedural programming skills or about a specifi c collection of tricks. Writing SQL well requires approaching problems with a different mind-set—one that is declarative and set oriented, not procedural. This is the dichotomy. Inside Microsoft SQL Server 2008: T-SQL Querying puts together all the ingredients you need to understand this declarative and set-oriented way of thinking and become a profi cient SQL programmer, thus making an important contribution to the SQL Server development community. Its chapters on formal foundations help you understand the basis for the language philosophy and get a sense for its potential. The language itself is covered thoroughly, from the basic operations to the most advanced features, all of them explained in the context of real problem solving. The many examples show you what good SQL looks like, and they cover common patterns you are likely to fi nd when writing applications. A comprehensive chapter on query tuning explains in detail the factors that impact performance in the system, how to go about identifying issues, and how to address them effectively. Itzik assembled a strong team of collaborators to write this book. Coming from different backgrounds, all of them share a deep expertise in SQL, a passion for database technology, extensive teaching experience, and a recognized track record of contributions to the SQL Server community. Steve Kass is known for his depth of understanding and clarity of thought. Dejan Sarka contributes an extensive knowledge of the relational model and a breadth of database technologies. As for Lubor Kollar, I’ve had the pleasure of working with him on the defi nition, design, and implementation of the Query Processing engine of SQL Server for over a decade, and I deeply respect his insight. They make an outstanding team of guides who can help you improve your skills.
I had met Itzik Ben-Gan briefl y a couple of times and knew of his reputation, so I was looking forward to his afternoon session on avoiding cursors in SQL programming at PASS. I was lucky to get there early, as the large room fi lled up quickly. Itzik took a couple of SQL programming problems and diced them up in the most skillful and entertaining way, showing the elegance and effi ciency of set-oriented thinking. The audience loved it—and so did I, except I had a different angle. Having worked on the internals of SQL Server, I could see Itzik touch the product nerves in his demos, and I admired how he turned features into beautiful solutions. After the session, I asked one of the attendees what had been his main takeaway, curious about which of the many techniques would have stood out for him. He looked at me, mildly surprised, and just said, “The man is a genius!” That pretty much sums it up. This question of cursors is more fundamental than it may appear at fi rst. It points to a deep dichotomy of tremendous practical importance. Most of us were taught to program by chopping up a task into smaller steps that, when executed in sequence, perform a desired computation. But if you approach SQL programming this way, you will get only mediocre results. Your code will be much larger and harder to maintain. It will be less effi cient, less fl exible, and less tunable. Using SQL effectively is not about an incremental extension of your procedural programming skills or about a specifi c collection of tricks. Writing SQL well requires approaching problems with a different mind-set—one that is declarative and set oriented, not procedural. This is the dichotomy. Inside Microsoft SQL Server 2008: T-SQL Querying puts together all the ingredients you need to understand this declarative and set-oriented way of thinking and become a profi cient SQL programmer, thus making an important contribution to the SQL Server development community. Its chapters on formal foundations help you understand the basis for the language philosophy and get a sense for its potential. The language itself is covered thoroughly, from the basic operations to the most advanced features, all of them explained in the context of real problem solving. The many examples show you what good SQL looks like, and they cover common patterns you are likely to fi nd when writing applications. A comprehensive chapter on query tuning explains in detail the factors that impact performance in the system, how to go about identifying issues, and how to address them effectively. Itzik assembled a strong team of collaborators to write this book. Coming from different backgrounds, all of them share a deep expertise in SQL, a passion for database technology, extensive teaching experience, and a recognized track record of contributions to the SQL Server community. Steve Kass is known for his depth of understanding and clarity of thought. Dejan Sarka contributes an extensive knowledge of the relational model and a breadth of database technologies. As for Lubor Kollar, I’ve had the pleasure of working with him on the defi nition, design, and implementation of the Query Processing engine of SQL Server for over a decade, and I deeply respect his insight. They make an outstanding team of guides who can help you improve your skills.

21,886

社区成员

发帖
与我相关
我的任务
社区描述
从PHP安装配置,PHP入门,PHP基础到PHP应用
社区管理员
  • 基础编程社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧