I have a table in mysql where thousands of phone calls are saved. Some telephone operators send telephone calls in multiple records. Phone calls are shuffled and must first be sorted by caller, called and date.
Here is an example
Id|Caller|Called|Date|Length|CallerImei|CallerImsi|CalledImei|CalledImsi|CallerCGIStart|CallerCGIEnd|CalledCGIStart|CalledCGIEND
"9"|"+39123"|"+39321"|"2018-08-03 03:10:18"|"351"|"8629"|"222"|""|""|"0117"|""|""|""
"16"|"+39222"|"+39111"|"2018-08-03 03:17:04"|"106"|"8629"|"222"|""|""|"4590"|""|""|""
"18"|"+39222"|"+39111"|"2018-08-03 03:17:04"|"106"|"" |""|"8629"|"222"|""|""|"4590"|""
"3"|"+39333"|"+39355"|"2018-08-03 03:06:23"|"146"|"8630"|"222"|""|""|"0117"|""|""|""
In the row with ids 16 and 18, the call is divided into two records. In line 16 there is some information, in row 18 there are others. We can recognize the call because it has the same date, same duration and the same caller and called. Also some phone calls may have more than two lines or the duration may be slightly lower, but if the previous phone call lasted longer than the one that follows it ... it is definitely the same phone call.
I would like to do a merge this way.
Id |Caller|Called|Date|Length|CallerImei|CallerImsi|CalledImei|CalledImsi|CallerCGIStart|CallerCGIEnd|CalledCGIStart|CalledCGIEND|ListIDMerged
"1"|"+39123"|"+39321"|"2018-08-03 03:10:18"|"351"|"8629"|"222"|""|""|"0117"|""|""|""|"9"
"2"|"+39222"|"+39111"|"2018-08-03 03:17:04"|"106"|"8629"|"222"|"8629"|"222"|"4590"|""|"4590"|""|"16,18"
"3"|"+39333"|"+39355"|"2018-08-03 03:06:23"|"146"|"8630"|"222"|""|""|"0117"|""|""|""|"3"
Then create a table with the result of the merge and a column that takes into account the merged rows for a possible control
Thanks for all
Related
I know this is a tough one but I'm basically trying to say. Give me a service call and its completion date, then give me the Max date for all service calls where the date is less than the date of the service call I'm inquiring about.
Basically the end result I'm looking for is to say was there another service call on this piece of equipment that was within the last 30 days.
So as you can see in the image for say Asset 50698 service call 579032 we have a date of 11/9/2020 the call below that was 10/22/2020 which was less than 30 days. I want to somehow find a way to count how many service calls I have where this has occurred. Is this possible?
I think you're looking for a context operator In, ForEach or ForAll (in in this case)
Add a variable "MaxAssetDate" and assign it a Formula similar to the following based on your column headers.
=Max([Service Call Completion Date] In ([Asset ID];[Service Call])) In (Asset ID])
Then add this as a column. Provided you have a prompt filtering for a given asset or "date" this column will then show the max date for each service call of the same asset ID. Then add a new variable: ServiceCallDaysDiff: Then by using DatesBetween() with "MaxAssetDate" and ServiceCallCompletionDate and DayPeriod; =DatesBetween([ServiceCallCompletionDate];[MaxAssetDate];DayPeriod) you should get a number 0-X. Then add a filter based if the number is between 1 and 30 then you show those records, otherwise hide the rest; or do whatever logic is then needed.
Now if you're dealing with hundreds of thousands of records this isn't ideal as you're putting all the processing on the webi engine when it ideally would occur as an object in the database layer. However if you only have a few thousand records this should be managable.
To add a count of service calls...
add variable: ServiceCallsCount:
=Sum(Sum(If([ServiceCallDaysDiff]=0;0;1)) In ([AssetID]))
this will count the non zero day differents. Note this will extend beyond 30 so if you want to limit by 30 days adjust the if statement to zero out those not between 1 and 30.
This is but one approach: there may be simpler ways.
I am working on a report in Access 2013 I need to seperate the first 20 records in a column that contain a value and assign a name to them. Such as at 1-20 I need it to insert Lot 1 at 21-40 need to assign Lot 2 etc... The report needs to be separated by lots of 20. I can also just insert a line when it reaches sets of 20 without a name if that makes it easier. Just need something to show a break at sets of 20.
Example: As you can see the report is separated by welder stencil. When the count in the VT column reaches 20 I need to enter a line or some type of divider to separate data. What our client is asking for is we separate the VT in sets of 20. I don't know whats the easiest way to accomplish this. I have researched it but haven't found anything.
Example Report with Divisions
Update the report's RecordSource query by adding "Lot" values for each row. There are multiple ways of doing this, but the easiest will be if your records already have a sequential, continuous numerical key. If they do not have such a key, you can research generating such sequential numbers for your query, but it is beyond the scope of this question and no details about the actual data schema were supplied in the question.
Let's imagine that you have such a key column [Seq]. You use the modulo (mod) and/or integer division operators (\ - backslash) to determine values that are exactly divisible by 20, e.g. ([Seq] - 1) mod 20 == 0.
Generate a lot value for each row. An example SQL snippet: SELECT ("Lot " & (([Seq] - 1) \ 20)) As LotNumber ...
Utilize Access report sorting and grouping features --grouping on the new Lot field-- to print a line and/or label at the start of each group. You can also have the report start a new page at the beginning or end of such a group.
The details about grouping can be found elsewhere in tutorials and Access documentation and are beyond the scope of this question.
I have an access database that tracks reports numbered in this way:
NNN-[two digit site code]-YY0000
The “0000” is a sequential number assigned as the reports are issued.
Examples are: NNN-SD-180001, NNN-MA-180002.
tbl_NNN stores the records.
NNN_ID is the column that stores the report numbers.
The report numbers are manually assigned, so we must keep track of the last assigned number to prevent “duplicating” the sequential 0000 number. Since users do not have visibility to the entire table of assigned numbers, they do not know which is the last number assigned. To assist them, their dashboard/form has a label that displays the last number issued. The problem we have is that the label only shows numbers that include the SD site code, MA numbers are not displayed.
My solution was to add a column named “Date_Created”, which adds a =Now() time stamp whenever a new row/number is created in the table. With the timestamp, I then intended to use Dmax to display the report number that corresponds to the last row created, regardless of the report number.
I know what I need is a combination of DLookup and Dmax, but what I came up with displays
"#Error"
in the label.
=DLookUp("NNN_ID","tbl_NNN","[Date_Created]=" & DMax("[Date_Created]","tbl_NNN"))
Am I writing this correctly?
You are close, but you must use single quotes (or unreadable expanded double quotes) for the embedded DMax:
=DLookUp("NNN_ID","tbl_NNN","[Date_Created] = DMax('[Date_Created]','tbl_NNN')")
I have a list (csv) of payments (and their timestamps) from certain phone numbers and a separate list (also csv) of subscriptions, plus start and end dates of the subscriptions for said phone numbers.
However, several phone numbers have had 2 subscriptions historically (ie. started one, stopped it, started a new one) and I need to associate each payment with the right subscription.
Essentially, I need a way to do
"FOR
this payment RETURN the subscription.id WHERE subscription.phonenumber=payment.phonenumber AND payment.timestamp IS BETWEEN sub.startdate AND sub.enddate".
How can I accomplish this with a formula? For those that only had a single subscription, I just did INDEX MATCH, however I can't see that working here
Let's say you put 2018-01-01 to A1 and 2018-12-31 to A2. Then the date to be tested (e.g. 2018-06-01) to A3. Put =IF(AND(A3>A$1;A3<A$2);"True";"False") to e.g. B3, this will give True. If you put 2019-06-01 to A3, it'll give you False.
I am trying to determine if there's a way to sort rows of a MySQL table that consists of start/finish columns. (Could also be thought of as parent/child relations or other linked list arrangement)
Here's an example of how the data is currently stored:
id start finish
2 stepthree stepfour
6 stepfive stepsix
9 stepone steptwo
78 stepfour stepfive
121 steptwo stepthree
(The id numbers in this are not relevant, just using them to indicate additional columns of arbitrary data)
I want to sort/display these row in order, presuming I am always starting with "stepone", that traverses the start-> finish chain like, each "finish" being followed by the row with it as a "start".
desired output
9 stepone steptwo
121 steptwo stepthree
2 stepthree stepfour
78 stepfour stepfive
6 stepfive stepsix
There shouldn't be any branching/splits normally, just a sequential series of steps or states. I can't use simple alpha sorting (in my case the start and finish values are codes created by a customer), but can't figure out any other way to order these using SQL. I could programmatically do it using most languages, but stumped about doing it just with SQL.
Any clever ideas?
I would recommend having another table that has each step mapped to its precedence order.
Then you can write a query to sort each row in the order of precedence of the start step.