很少(员工 - 轮班)SQL 数据库帮助
我正在创建一个包含员工、emp_shift、shift、表的小数据库 现在我想能够在月底计算出哪个员工 已经完成了最多的轮班次数。
我已经创建了 SQL 创建、表的插入语句以及一个小图表来解释我想要完成的任务,我是一个初学者,这是我过去 4 天一直在尝试做的作业。
图表:http://latinunit.net/emp_shift.jpg SQL:http://latinunit.net/emp_shift.txt
请大家检查一下,截止日期是2天,这只是整个数据库的一部分
Im creating a little database that has employee, emp_shift, shift, tables
now im suppose to be able to calculate at the end of the month which employee
has done the most number of shifts.
Ive created the SQL creation, insert statements for the tables, and a little diagram to explain what im trying to acomplish, im a beginner and this is a homework ive been trying to do for the last 4 days.
Diagram: http://latinunit.net/emp_shift.jpg
SQL: http://latinunit.net/emp_shift.txt
can you please guys check it, deadline is 2 days and this is just a part of the whole database
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这是一个合理的开始。可以多放几张桌子吗?如果没有,就很难确定如何向人们付款——例如,您似乎可能需要一个“付款周期”表。然后,您可以找到开始日期和结束日期,并能够计算该期间内的班次。
但如果您需要做的正是您所说的,那么这是一个公平的开始。
(我假设您还有其他列,例如员工姓名,但这很明显)。
That is a reasonable start. Will you have more tables? If not, it will be hard to identify how to pay people -- for example, it seems that you might want a "pay-period" table. Then you could find the start and end dates and be able to count the shifts within that period.
But if all you need to do is exactly what you said, that is a fair start.
(I am assuming you have other columns in mind, such as employee name, but that would be obvious).
您可以首先告诉我们您正在使用哪个 RDBMS,因为 RDMS 之间的一些更详细的细节可能有所不同。
您需要在表之间创建一个链接(称为 JOINS,阅读此内容),然后执行 请求数据的计数。
阅读其中一些内容后,请向我们展示您所做的事情,我们可以帮助您解决遇到的问题。
You could start by telling us whoch RDBMS you are using, as some of the finer details might be different between RDMSs.
You need to create a link between tables (Called JOINS, Read this) and then perform a count of the requested data.
After you have read some of these, show us what you have done, and we can help you where you are having trouble.
此外,使用单个数字作为主键而不是“A”、“B”、“C”等会更实用。
also, it would be better practive to use a single numeric as the primary key instead of 'A', 'B', 'C' etc.