Click here to Skip to main content
15,893,381 members
Home / Discussions / Database
   

Database

 
GeneralRe: problem with SQLparameter? Pin
Mr.Kode20-May-08 23:20
Mr.Kode20-May-08 23:20 
GeneralRe: problem with SQLparameter? Pin
Unknown Ajanabi20-May-08 23:50
Unknown Ajanabi20-May-08 23:50 
AnswerCP Ignore Pin
leckey21-May-08 3:20
leckey21-May-08 3:20 
Questiondistinct? Pin
laserbaronen20-May-08 21:40
laserbaronen20-May-08 21:40 
AnswerRe: distinct? Pin
Blue_Boy20-May-08 22:47
Blue_Boy20-May-08 22:47 
QuestionRe: distinct? Pin
laserbaronen20-May-08 22:51
laserbaronen20-May-08 22:51 
AnswerRe: distinct? Pin
Blue_Boy20-May-08 22:53
Blue_Boy20-May-08 22:53 
GeneralRe: distinct? Pin
laserbaronen20-May-08 23:02
laserbaronen20-May-08 23:02 
I have a table called Messages, where many messages can share the same InterchangeId

I also have a function to get the processing time for an interchange, it looks like this:

ALTER function [dbo].[GetProcessingTime] ( @interchangeId uniqueidentifier )
returns int
AS
BEGIN
DECLARE @recDate DateTime
DECLARE @sendDate DateTime
DECLARE @return int

-- Get receivetime
select top 1 @recDate = mf.[Event/Timestamp] from    dbo.Ports p INNER JOIN
                      BizTalkDTADb.dbo.dtav_MessageFacts mf 
INNER JOIN
                      dbo.Messages m ON mf.[MessageInstance/InstanceID] = m.MessageId ON 
                     p.Name = mf.[Event/Port] INNER JOIN
                      dbo.PortTypes pt ON p.FK_PortType = pt.Id
WHERE pt.Description='ReceivePort'  and m.[InterchangeId] = @interchangeId
order by mf.[Event/Timestamp] asc  --first

select top 1 @sendDate = mf.[Event/Timestamp] from    dbo.Ports p INNER JOIN
                      BizTalkDTADb.dbo.dtav_MessageFacts mf 
INNER JOIN
                      dbo.Messages m ON mf.[MessageInstance/InstanceID] = m.MessageId ON 
                     p.Name = mf.[Event/Port] INNER JOIN
                      dbo.PortTypes pt ON p.FK_PortType = pt.Id
WHERE pt.Description='SendPort'  and m.[InterchangeId] = @interchangeId
order by mf.[Event/Timestamp] desc  -- latest

set @return = DATEDIFF(millisecond ,@recDate,@sendDate)
return @return
END


It gets the time difference between the first and the last message in the interchange in milliseconds.
Now what i want to do is:
get the average processing time for each unique interchange

hence:
ALTER proc [dbo].[GetAverageProcessingTime](@startDate datetime, @endDate datetime)
as
select avg(distinct dbo.GetProcessingTime(InterchangeId)) from Messages where WrittenDate between @startDate and @endDate
am confused about the distinct in the last procedure, it feels.. wrong Smile | :)


betonglasermur.FeedDwarf(pur_is, 17);
ProcessStartupInfo.AintNotCreateNoWindow = (false && !true) != (true || false) ? false == true ? true : false : (true != false && false);

Morgonen är tröttmans mecka

GeneralRe: distinct? Pin
Blue_Boy20-May-08 23:19
Blue_Boy20-May-08 23:19 
GeneralRe: distinct? Pin
laserbaronen20-May-08 23:31
laserbaronen20-May-08 23:31 
GeneralRe: distinct? Pin
Blue_Boy20-May-08 23:32
Blue_Boy20-May-08 23:32 
QuestionPrimary Keys Pin
MAW3020-May-08 16:50
MAW3020-May-08 16:50 
AnswerRe: Primary Keys Pin
ChandraRam20-May-08 21:00
ChandraRam20-May-08 21:00 
QuestionInner Join to match multiple rows in lookup table Pin
redivider20-May-08 10:59
redivider20-May-08 10:59 
AnswerRe: Inner Join to match multiple rows in lookup table Pin
WoutL20-May-08 20:12
WoutL20-May-08 20:12 
GeneralRe: Inner Join to match multiple rows in lookup table Pin
redivider21-May-08 4:57
redivider21-May-08 4:57 
Questionsql very long?? Pin
foryou20-May-08 1:52
foryou20-May-08 1:52 
GeneralHelp me please. Pin
foryou21-May-08 1:53
foryou21-May-08 1:53 
QuestionRetrieve from DataBase Pin
Mr. Wonderful20-May-08 0:02
Mr. Wonderful20-May-08 0:02 
AnswerRe: Retrieve from DataBase Pin
Blue_Boy20-May-08 3:14
Blue_Boy20-May-08 3:14 
QuestionWhy the exception "Could not save; currently locked by another user" is coming? Pin
nicolus19-May-08 23:50
nicolus19-May-08 23:50 
QuestionLoad file in SQL Server from FileSystem Pin
JoZ CaVaLLo19-May-08 23:24
JoZ CaVaLLo19-May-08 23:24 
QuestionSql server reporting service 2005 - Drill down problem Pin
veereshIndia19-May-08 22:26
veereshIndia19-May-08 22:26 
AnswerCP Ignore Pin
leckey20-May-08 3:27
leckey20-May-08 3:27 
QuestionSql Server 2005 reporting service-Toggle problem Pin
veereshIndia19-May-08 22:15
veereshIndia19-May-08 22:15 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.