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
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Datetime of Max(QTime)

Author  Topic 

sonnysingh
Starting Member

42 Posts

Posted - 2010-04-16 : 03:56:43
Hi All

I need to include in same T-SQL the datetime for 'MaxLQTimeAbdn.

This data group by datetime column. And need datetime for max(QTime) means datetime for 16 value of Qtime.

HalfHourDateTime DateTime DNIS QTime
2010-04-01 02:30:00 2010-04-01 02:51:42 15403 10

2010-04-01 02:30:00 2010-04-01 02:52:14 15403 16


T-SQL as follows:-

SELECT @Hnd.RHalfHour, @Abnd.Variable3,
COUNT(@Abnd.RCKey) as 'TrueAbandons', SUM(@Abnd.LocalQTime) as 'LocalQTime',
MAX(@Abnd.LocalQTime) as 'MaxLQTimeAbdn',
FROM
@Hnd
RIGHT OUTER JOIN
@Abnd
ON @Hnd.NewRouterCallKey = @Abnd.NewRouterCallKey
WHERE @Hnd.NewRouterCallKey is null
GROUP BY @Abnd.Variable3 , @Abnd.RHalfHour

Thanks for Help




SqlIndia

Sachin.Nand

2937 Posts

Posted - 2010-04-16 : 04:03:10
It's helpful if you can post your table strcuture (and sample data). Here is a link that helps explain what will help us to help you better:

http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

PBUH
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2010-04-16 : 04:15:42
Idera is right.
In your post there is no question.
There is already a select with max(@Abnd.LocalQTime).
There is already an error because the last comma before FROM isn't right.
You should have posted the error message.

You have given a little bit of sample data but you have not given the wanted output.


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page
   

- Advertisement -