Applying Data Mining with only SQL is considered very rare, but it is actually possible to solve some problems. As you can read in the article A Genetic Algorithm Sample in T-SQL by William Talada, it can solve a quite interessting problem.
A field with 10×10 squares is covered to the half with empty cans, it is bordered by a impassable wall. Now a poor tiny robot is send to clear the whole field. He can walk in any direction or pick up a can. His view is reduced to 5 squares, the one he stands on am the four fields that adjoin.
A square can have three conditions. It can be empty, be a border or can contain a can. Since the bot can only see five squares, there are 3x3x3x3x3 = 243 possibilities to consider. The robot can do six actions on every square; he can move in any direction, pick up a can or – additionally – he can move by chance. That are 243^6 = 1,23×10^189 possibilities or steps to try. That are far to much to be computed regularly – so you need something better.
The algorithm that was shown by William Talada is very efficient – it only takes about a million steps to come to a nearly ideal solution.
The result is counted by the following measures. A picked up can makes +10, crushing into the wall is -5, and grasp the void is -1. So the Bot can make about 500 points in a perfect run.
The script for this algorithm is in the article and shows how it works. The duration of 20min is quite fast and very efficient.
The idea originally comes from the book “Complexity: A Guided Tour” by Melanie Mitchell, according to William Talada. The book gives a good overview about recent research and possibilities of complex systems, and how to apply them hands-on.