Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Horizontal line space

Author  Topic 

crazyco
Starting Member

30 Posts

Posted - 2011-03-17 : 10:06:53
Is there a way to add a line space within this code so that after each 'Total' (or above date groups) there is a blank line making it easier to read?

SELECT REPLACE([Staff Name],'_','') as [Staff Name], Hours, Date, [Records Entered For Shift], [Records Entered Per Minute]
FROM
(SELECT forenames + ' ' + surnames as [Staff Name], dbo.mins_to_hours(SUM(dbo.hours_to_mins(Duration))) as Hours, CONVERT(varchar(10), start_date, 103) AS Date,
SUM(Cast(Outcome as int)) as [Records Entered For Shift],
Cast(SUM(Cast(Outcome as Decimal)) / SUM(dbo.hours_to_mins(Duration)) as decimal(8,2)) as [Records Entered Per Minute]
FROM Staff_Tasks st LEFT JOIN Staff s ON st.StaffID = s.StaffID
LEFT JOIN Jobs j ON st.job_id = j.job_id
WHERE s.surnames IS NOT NULL
AND project_id = 2
group by start_date, forenames, surnames
UNION
SELECT '_Total' as [Staff Name], dbo.mins_to_hours(SUM(dbo.hours_to_mins(Duration))) as Hours, CONVERT(varchar(10), start_date, 103) AS Date,
SUM(Cast(Outcome as int)) as [Records Entered For Shift],
Cast(SUM(Cast(Outcome as Decimal)) / SUM(dbo.hours_to_mins(Duration)) as decimal(8,2)) as [Records Entered Per Minute]
FROM Staff_Tasks st LEFT JOIN Staff s ON st.StaffID = s.StaffID
LEFT JOIN Jobs j ON st.job_id = j.job_id
WHERE s.surnames IS NOT NULL
AND project_id = 2
group by start_date) UnionTable
order by Date

jimf
Master Smack Fu Yak Hacker

2875 Posts

Posted - 2011-03-17 : 10:25:24
Probably. But this should be done in the front end. I would focus on making your code easier to read, rather than the results.


Jim

Everyday I learn something that somebody else already knew
Go to Top of Page
   

- Advertisement -