i have 4 tables, structured follows:
more verbosely, project consists of set of tasks. employee can add 1 or more notes database, specifying amount of time spent on task on given date.
i find each employee, how long he's worked on given task in total, between 2 dates. first stab @ follows:
select project.name projectname, task.name taskname, employee.name employeename, sum(note.workduration) note inner join employee on note.id_employee = employee.id inner join task on task.id = note.id_task inner join project on task.id_project = project.id note.workdate between '01/05/2015' , '08/05/2015' group task.name, project.name, employee.name order employee.name asc
however given wrong value populated database. can me understand how this?
the idea somehow make query write excel table, projects/tasks along y , employee name along x, each cell containing total time worked on task.
update: if change between clause to:
note.[date] between '20150501' , '20150508'
it seems work correctly. have date format issue.
"so started doing , saw when selecting records - between clause isn't working correctly. set dates above , i'm getting records march in there too. have done wrong date format such it's being converted somehow? – robinson 18 mins ago"
it depends on you're , default settings date format; guess you're not (since seem put day before month in '01/05/2015'), bet server's format set standards (month/day/year). see https://msdn.microsoft.com/en-us/library/ms189491.aspx
the safest thing use universal standard did in second try: yyyymmdd (or better: yyyy-mm-dd).
Comments
Post a Comment