i have two tables .. one is a master table and other one is an daily report table.
Master table :
machine_id Machinename
1 abc
2 def
3 ghi
4 jkl
ven_fullreportmaster :
entry_date machine_id description_id tot_time shift_id
20110613 1 1 10 1
20110613 2 2 9 2
20110614 1 1 10 1
20110614 1 2 9 2
20110614 3 3 5 3
20110614 2 4 10 1
20110614 2 1 9 2
20110614 2 5 5 3
now, i want to retrieve the data from the daily report table that it should contain all the machine names with tot_time and entry_date..
i have used this query to retrieve the data,
select entry_date,
machinename,
(IsNull(cast(TotalMins / 60 as varchar(24)),'0') + ':' + IsNull(cast(TotalMins % 60 as varchar(24)),'0')) as TotalHrs--, shift_type
from (
select vm.machinename , vfrm.entry_date,
sum(case when vfrm.description_id in ('1','2','3','4','5') then DateDiff(mi, 0, total_time) else '0' end) as TotalMins
--vsm.shift_type
from ven_fullreportmaster vfrm
inner join ven_machinemaster vm on vm.machine_id = vfrm.machine_id
inner join ven_shifttypemaster vsm on vsm.shift_id = vfrm.shift_id
where vfrm.entry_date = '20110614'
-- and vfrm.shift_id in (1,2,3)
group by machinename, vfrm.entry_date --, vsm.shift_type
) as SubQueryALias group by entry_date, machinename,TotalMins --,shift_type
when i run the above query, i am getting details for machine-id 1 , 2,3 alone..
output:
entry_date machineid TotalHrs
2011-06-14 00:00:00.000 1 19:0
2011-06-14 00:00:00.000 2 24:0
2011-06-14 00:00:00.000 3 5:0
i need to get machine_id =4 value as 0 in TotalMins for each shift.. how to resolve it..plz help me ..
expected output:
entry_date machineid TotalHrs
2011-06-14 00:00:00.000 1 19:0
2011-06-14 00:00:00.000 2 24:0
2011-06-14 00:00:00.000 3 5:0
**2011-06-14 00:00:00.000 4 0:0**
thanks and regards
T.Navin

output:
