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.
| Author |
Topic |
|
sqlnewb
Starting Member
2 Posts |
Posted - 2006-05-17 : 10:38:06
|
| I have a big presentation tomorrow and I have a query I'm trying tomake a little more presentable. query text itself formatted (filtering data)Tables:--tpeople--tsynclogThe query:select Firstname+' '+Lastname as [FirstName LastName],synctime as[Nestle synctime],sum(DurationInMinutes)from tpeoplejoin tsynclog on people_id = idwhere synctime > '2006-05-05'group bytpeople.FirstName,tsynclog.people_id,tpeople.LastName,tsynclog.SyncTimehaving sum(DurationInMinutes) > 100order by synctime descAs you can see I need some alias added and maybe the whole thing formatted a littledifferent. Can anyone help?Thanks. |
|
|
RyanRandall
Master Smack Fu Yak Hacker
1074 Posts |
Posted - 2006-05-17 : 11:08:56
|
Here's some aliases added and better formatting. Is that all you were after?select p.Firstname + ' ' + p.Lastname as [FirstName LastName], s.synctime as [Nestle synctime], sum(s.DurationInMinutes) as [DurationInMinutes]from tpeople p inner join tsynclog s on s.people_id = p.idwhere s.synctime > '2006-05-05'group by p.FirstName, s.people_id, p.LastName, s.SyncTimehaving sum(s.DurationInMinutes) > 100order by s.synctime desc Ryan Randallwww.monsoonmalabar.com London-based IT consultancy Solutions are easy. Understanding the problem, now, that's the hard part. |
 |
|
|
sqlnewb
Starting Member
2 Posts |
Posted - 2006-05-17 : 14:42:54
|
| This is what I came up with but it seems broken Select Firstname+' '+Lastname As [Firstname Lastname] ,x.synctime As [Nestle Synctime] ,Sum(Durationinminutes) As [Duration In Minutes] From Tpeople p Join Tsynclog sl On sl.People_Id = p.Idjoin ( select people_id, max(synctime) as synctime from tsynclog where Durationinminutes is null group by people_id ) x on x.people_id = sl.people_id where sl.Synctime > '2006-05-05'Group By p.Firstname ,sl.People_Id ,p.Lastname ,x.SynctimeHaving Sum(Durationinminutes) > 100 Order By x.Synctime Desc |
 |
|
|
|
|
|
|
|