In addition, this SQL is far less than straightforward for many programmers. A better solution is to make use of a stored function in SQL. Instead of creating a view, create a function that performs exactly the