sql - Getting the sum of a specific row -
i have maintenance table named ticket
table , transaction table called workplan
.
ticket table contains tickedid
, ticketname
, startdate
,estimated time of completion
, total number of hours
columns.
and workplan
table has workplanid
, ticketid(foreignkey)
, currentdate
, ticket name
, no of hours
, , hours remained
columns.
for instance:
i have ticket entry shown below.
ticket id / ticket name / start date / estimated time of c. /total number of hours 1 /sample name / 05.21.2013 / 05.23.2013 / 21hours
and next table represents workplan
.
workplanid / ticket id / currentdate / ticket name / no of hours / hours remained 1001 /1 / may.21.2013 /sample name /3 /18
...workplan id autogenerated.
if user manage his/her workplan. current date automatically derived. user input his/her no of hours.
my question how can difference between total number of hours ticket table , hours remained in workplan table?
so if user has managed workplan again next day,
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
im using vb.net , sqlserver backend.
(binding source)
the lower value of hours_remained
per ticket on last user update. so:
select total_number_of_hours - min(hours_remained) workplan, ticket ticket.ticket_id = workplan.ticket_id;
Comments
Post a Comment