1

it's my first time posting here but this site has supplied me with lots of answers in the past so I'll give it a try.

Background information: I'm using Acces 2013, connecting to a MySQL database through ODBC 3.51.

I'm busy pulling reports out of a Call Detail record, namely I want to make an overview of the times different employees have spent receiving and making outgoing calls on different phone lines.

I have already found out I can't make two seperate TRANSFORM...PIVOT query's and UNION those. That makes sense, because there's no way the code knows my 2 query's will return the same amount of Pivots.

Is it possible to turn this process around? (First collect the data you need in a UNION, and then transforming the data).

I created the following Union query collecting the relevant data:

(SELECT dbo_IpPbxCDR.DestinationName AS [Name], Sum(DateDiff('n',[dbo_IpPbxCDR.starttime],[dbo_IpPbxCDR.endtime])) AS [Called Time], IIf((dbo_IpPbxCDR.CalledName Like "*0900*") OR (dbo_IpPbxCDR_1.CalledName like "*0900*"), "0900", "abo") AS [Called Line]
FROM (dbo_IpPbxCDR AS dbo_IpPbxCDR_1 RIGHT JOIN dbo_IpPbxCDR ON dbo_IpPbxCDR_1.CallId = dbo_IpPbxCDR.TransferredCallId2)
WHERE <Where clause relevant to the data I want. It’s pretty long so I omitted it>
GROUP BY dbo_IpPbxCDR.DestinationName, IIf((dbo_IpPbxCDR.CalledName Like "*0900*") OR (dbo_IpPbxCDR_1.CalledName like "*0900*"), "0900", "abo"))
UNION
(SELECT dbo_IpPbxCDR.OriginationName AS [Name], Sum(DateDiff('n',[dbo_IpPbxCDR.starttime],[dbo_IpPbxCDR.endtime])) AS [Called Time], 'uit' AS [Called Line]
FROM dbo_IpPbxCDR
WHERE <Where clause relevant to the data I want. It’s pretty long so I omitted it>
GROUP BY dbo_IpPbxCDR.OriginationName)

I'm trying to transform on Sum(DateDiff('n',[dbo_IpPbxCDR.starttime],[dbo_IpPbxCDR.endtime])) so I can get data relevant to certain months with pivot Month([dbo_IpPbxCDR.starttime])

I'd appreciate any help/advice I can get!

4

0 に答える 0