sql - show rows with no data in access -
i have following query:
select persontotalhours.ma, persontotalhours.year, persontotalhours.calendarweek, persontotalhours.hours, person.name, person.lastname persontotalhours inner join person on persontotalhours.ma = person.ma;
which results in following table:
ma year calendarweek hours name lastname aa 2000 5 53 aa aa aa 2000 44 175 aa aa ... ... ... ... aa 2001 4 226 aa aa aa 2001 12 87 aa aa ... ... ... ... bb 2000 1 189 bb bb bb 2000 35 65 bb bb ... ... ... ...
as can see, there no data calendar weeks. there way can have row calendar weeks(1 53) , hours=0 ones don't exist now?
edit have solve temporarily adding missing row table. using function called when report opens. still looking non-stupid solution.
create table calendar
, storing possible values. right join
it:
select pth.ma, pth.year, pth.calendarweek, pth.hours, p.name, p.lastname persontotalhours pth inner join person p on pth.ma = p.ma right join calendar c on pth.year = c.year , pth.calendarweek = c.calendarweek
(using table aliases spare typing.)
edit: ms access query attempt, version 1:
select pth.ma, pth.year, pth.calendarweek, pth.hours, p.name, p.lastname (persontotalhours pth inner join person p on pth.ma = p.ma) right join calendar c on pth.year = c.year , pth.calendarweek = c.calendarweek
edit: ms access query attempt, version 2:
select pth.ma, pth.year, pth.calendarweek, pth.hours, p.name, p.lastname calendar left join (persontotalhours pth inner join person p on pth.ma = p.ma) on pth.year = c.year , pth.calendarweek = c.calendarweek
Comments
Post a Comment