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 2008 Forums
 Transact-SQL (2008)
 Group by Clause between datetime

Author  Topic 

SubhaGunjan
Starting Member

1 Post

Posted - 2014-06-02 : 05:51:05
In my Table data are like below format.
========= ========= ========= ============
Client ID Ticker ID Broker ID Receive Time
========= ========= ========= ============
A T1 M1 5/22/2014 9:40
A T1 M2 5/23/2014 11:40
A T1 M3 5/24/2014 9:40
A T2 M4 5/25/2014 7:40
B T1 M1 5/26/2014 9:10
B T1 M2 5/27/2014 0:40
B T2 M3 5/28/2014 18:40


I need output between datetime field as

Client ID Ticker ID Broker ID Receive Time
========= ========= ========= ============
A T1 M2,M3
A T2 M4
B T1 M1,M2

using below query I got result but not based on time



SELECT
[Client ID], [Ticker ID],
STUFF(
(SELECT ',' + [Broker ID]
FROM [Intrabase].[dbo].[ModelList]
WHERE [Client ID] = a.[Client ID] and [Ticker ID] = a.[Ticker ID]
FOR XML PATH (''))
, 1, 1, '') AS BrokerList
FROM [Intrabase].[dbo].[ModelList] AS a

GROUP BY [Client ID],[Ticker ID]


please suggest me how can i get output.

gbritton
Master Smack Fu Yak Hacker

2780 Posts

Posted - 2014-06-02 : 09:47:53
What specific output would you like to see with the data you supplied? Please the desired results.
Go to Top of Page
   

- Advertisement -