[英]Getting the sum of a specific row
我有一個名為ticket
表的維護表和一個名為workplan
的交易表。
工單表包含tickedID
, ticketName
, startdate
, estimated time of completion
和total number of hours
列。
然后, workplan
表中有workplanID
, ticketID(foreignkey)
, currentdate
, ticket name
, no of hours
和hours remained
列。
例如:
我有如下所示的門票條目。
ticket ID / ticket name / start date / estimated time of c. /total number of hours
1 /sample name / 05.21.2013 / 05.23.2013 / 21hours
下表代表workplan
。
workplanID / ticket ID / currentdate / ticket name / no of hours / hours remained
1001 /1 / may.21.2013 /sample name /3 /18
... Workplan ID is autogenerated.
用戶是否管理自己的工作計划。 當前日期將自動得出。 用戶將輸入他/她的小時數。
我的問題是如何從工單表中獲得的總小時數與工作計划表中剩余的小時數之間的差額?
因此,如果用戶第二天再次管理了他的工作計划,
workplanID / ticket ID / currentdate / ticket name / no of hours / hours remained
1001 /1 / may.21.2013 /sample name /3 /18
1002 /1 / may.22.2013 /sample name /4 /14
我使用vb.net和sqlserver作為后端。
(綁定源)
每張票證的hours_remained
的較低值將始終在最后一次用戶更新上。 所以:
SELECT total_number_of_hours - MIN(hours_remained)
FROM workplan, Ticket
WHERE Ticket.ticket_ID = workplan.ticket_ID;
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.