473,378 Members | 1,479 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

SQL Problem - Date / Txn Sequences

People,

I'm trying to figure if SQL is able find sequences of transactions that
occur over say a four day period.

I have a table that contains a txn id [integer] and a date. Each
transaction might occur say 30 times within the first quarter of a
year, so there would be 30 records in the table [ID, DATE] for each
txn. There may be say 50k transactions. What I am trying to do is find
subsequent transactions that appear the day after the initial occurence
of a specific transaction up to say a limit of 4 times in a row.

ie: If txn 1 occures 30 times on various dates, then which transactions
are found to be ocurring on the subsequent date and so on. The
following transactions do not necessarily have to occur on all 30
subsequent dates, so they can be variances. What I would like to find
is a say a set of x many sequences that always occur say 6 times out of
the 30 possible dates. Meaning that this sequence of four dates,
started on these x dates and happened say 6 times.

So txn 1 was followed by txn 497, which was followed by txn 9673, which
was followed by txn 25675. The sequence happened 6 times and started on
these x,x,x,x,x,x dates.

Is this even possible in SQL ? I've tried converting the dates to
integers and using a date_id +/- 1 calculation to link what happens
next or previous, but I can't get it to work on a sequence of say four
in a row.

Anyone got any bright ideas, I'd greatly appreciate the help.

Many thanks. Tim

Nov 12 '05 #1
4 1883
I am not sure whether the frequent pattern search algorithm or the
apriori algorithm for association rule mining would help.

Nov 12 '05 #2


db2newbie wrote:
I am not sure whether the frequent pattern search algorithm or the
apriori algorithm for association rule mining would help.


I could use a mining algorithm and have in the past, but for this piece
I was hoping SQL could answer the query in a more timely fashion.

Nov 12 '05 #3
I guess this is not possible then huh ?

p175 wrote:
People,

I'm trying to figure if SQL is able find sequences of transactions that
occur over say a four day period.

I have a table that contains a txn id [integer] and a date. Each
transaction might occur say 30 times within the first quarter of a
year, so there would be 30 records in the table [ID, DATE] for each
txn. There may be say 50k transactions. What I am trying to do is find
subsequent transactions that appear the day after the initial occurence
of a specific transaction up to say a limit of 4 times in a row.

ie: If txn 1 occures 30 times on various dates, then which transactions
are found to be ocurring on the subsequent date and so on. The
following transactions do not necessarily have to occur on all 30
subsequent dates, so they can be variances. What I would like to find
is a say a set of x many sequences that always occur say 6 times out of
the 30 possible dates. Meaning that this sequence of four dates,
started on these x dates and happened say 6 times.

So txn 1 was followed by txn 497, which was followed by txn 9673, which
was followed by txn 25675. The sequence happened 6 times and started on
these x,x,x,x,x,x dates.

Is this even possible in SQL ? I've tried converting the dates to
integers and using a date_id +/- 1 calculation to link what happens
next or previous, but I can't get it to work on a sequence of say four
in a row.

Anyone got any bright ideas, I'd greatly appreciate the help.

Many thanks. Tim


Nov 12 '05 #4
p175 wrote:
I guess this is not possible then huh ?

p175 wrote:
People,

I'm trying to figure if SQL is able find sequences of transactions that
occur over say a four day period.

I have a table that contains a txn id [integer] and a date. Each
transaction might occur say 30 times within the first quarter of a
year, so there would be 30 records in the table [ID, DATE] for each
txn. There may be say 50k transactions. What I am trying to do is find
subsequent transactions that appear the day after the initial occurence
of a specific transaction up to say a limit of 4 times in a row.

ie: If txn 1 occures 30 times on various dates, then which transactions
are found to be ocurring on the subsequent date and so on. The
following transactions do not necessarily have to occur on all 30
subsequent dates, so they can be variances. What I would like to find
is a say a set of x many sequences that always occur say 6 times out of
the 30 possible dates. Meaning that this sequence of four dates,
started on these x dates and happened say 6 times.

So txn 1 was followed by txn 497, which was followed by txn 9673, which
was followed by txn 25675. The sequence happened 6 times and started on
these x,x,x,x,x,x dates.

Is this even possible in SQL ? I've tried converting the dates to
integers and using a date_id +/- 1 calculation to link what happens
next or previous, but I can't get it to work on a sequence of say four
in a row.

Anyone got any bright ideas, I'd greatly appreciate the help.

Many thanks. Tim


It is possible. But it woudl be better if you gave sampelinput and
sampel output.
You may want to take a look at OLAP expressions. In particluar teh
windowing capabilities.

Cheers
Serge

--
Serge Rielau
DB2 SQL Compiler Development
IBM Toronto Lab
Nov 12 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: temp | last post by:
Hi All, I wonder could someone help me with this? What I want to do is search through a list of letters and look for adjacent groups of letters that form sequences, not in the usual way of...
15
by: Paul J. Ettl | last post by:
Two questions: I use var date1 = new Date(); to get todays date. But how can I get yesterdays date? Furthermore I use
4
by: Bob Sanderson | last post by:
I have a script that reads the computer date and writes it to a copyrite footer on a web page. The idea is to avoid having to update each page manually at the start of a new year. It works fine...
6
by: Franz | last post by:
Hy all, I have a problem with a date in javascript on firefox Browser. I use this javascript method: var dataNow=new Date(); var dd=dataNow.getDate(); var mm=dataNow.getMonth()+1; var...
10
by: Vilson farias | last post by:
Greetings, I'm getting a big performance problem and I would like to ask you what would be the reason, but first I need to explain how it happens. Let's suppose I can't use sequences (it seams...
18
by: Bruno Baguette | last post by:
Hello, I have to design a table wich will store some action reports. Each report have an ID like this 1/2004, 2/2004, ... and each years, they restart to 1 (1/2004, 1/2005, 1/2006,...). So, I...
5
by: Michael Fuhr | last post by:
I'd like to propose that certain GRANTs on a table cascade to the table's implicit sequences. In the current implementation (as of 7.4.5 and 8.0.0beta3), a table owner must typically issue GRANT...
17
by: Petyr David | last post by:
Just looking for the simplest. right now my perl script returns an error messge to the user if the date string is invalid. would like to do this before accessing the server. TX
4
by: JJ | last post by:
Is there a way of checking that a line with escape sequences in it, has no strings in it (apart from the escape sequences)? i.e. a line with \n\t\t\t\t\t\t\t\r\n would have no string in it a...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.