﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>SQLServerCentral / SQL Server 2008 / SQL Server Newbies  / Query to sum total time / Latest Posts</title><generator>InstantForum.NET v2.9.0</generator><description>SQLServerCentral</description><link>http://www.sqlservercentral.com/Forums/</link><webMaster>notifications@sqlservercentral.com</webMaster><lastBuildDate>Thu, 20 Jun 2013 03:54:09 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: Query to sum total time</title><link>http://www.sqlservercentral.com/Forums/Topic1045333-1292-1.aspx</link><description>Hey Cagan,Welcome to SSC.  It would be easier to help you if you check out the first link in my sig, which will walk you through proving some sample structure and data so that we could write code to show you want you want to do, as well as explaining what said code is doing.In short, you need two separate statements.  One doing the SELECT COUNT ( DISTINCT encounter_number) with no GROUP BY, and another doing a SELECT SUM( DATEDIFF()) FROM tbl GROUP BY Encounter_Number.</description><pubDate>Mon, 10 Jan 2011 09:42:05 GMT</pubDate><dc:creator>Evil Kraig F</dc:creator></item><item><title>Query to sum total time</title><link>http://www.sqlservercentral.com/Forums/Topic1045333-1292-1.aspx</link><description>I am having trouble writing a query that will some the total time for an event.  I have 2 columns of data, Encounter_Code, Duration.  I need the total unique number of Encounter_Code, My code for this part is Count(Encounter_Code) AS Total, and this is working, but when I try and sum the total duration of every event for one Encounter_Code I don't know where to start.  Any suggestions?Thanks</description><pubDate>Mon, 10 Jan 2011 08:07:28 GMT</pubDate><dc:creator>cagan</dc:creator></item></channel></rss>