Showing posts with label Sequence. Show all posts
Showing posts with label Sequence. Show all posts

Add Sequence Number to an Existing Table in MS Access


Add series number to an existing table can be done by following method:

SELECT t.myDate, (
    SELECT Count(*)
    FROM myTable AS s
    WHERE t.myDate <= s.myDate) as myRank
FROM myTable AS t

However, if it does not work for you, try following option:

Alter Table Temp_SequenceChange Add Column SequenceNo AutoIncrement;


Add Sequential Number Column in SQL Query Result

To add a column with sequential number in SQL query can be done through add a sequence numbered table contains a link key or directly compose in query. The first method sounds unwise, but if the query itself is too complicated, it might not be a bad idea.

The second method is:

SELECT
(
SELECT COUNT(au_id)
FROM Mytable1 AS x
WHERE x.au_id <= y.au_id
) AS Sequence
, au_id
, something_else
FROM Mytable1 AS y
ORDER BY au_id

This constrains here are:
1. Field au_id must be number.
2. The query itself can’t be too complicated.
3. If Mytable is from another query, if won’t work properly in some systems, such as SQL Server.


http://www.databasejournal.com/features/mssql/article.php/3373861/Auto-Number-and-Cumulative-sum-in-SQL-Server-Query-results.htm

Sequential and Modular Programming

Modular Programming came out as a newer technique. In terms sequence to execute the programing blocks, or called modules, modular programming also means the run time automatically searching where the modules are. Unfortunately, different language sets it differently, some are better and some are not so good. Object-oriented languages are all modular programming and they are the best in this regarding.

PL/SQL

PL/SQL is sequential language and its modules searching function is very bad. It means you would have to put functions/procedures in right order within the package to enable the sequential process. Of course, for packages itself it has no problem since packages are individual files.

Java

Java is a fully object-oriented language, though within the class, it is still the sequential. However, methods within the class are also fully modularized. It means the position of methods plays no role, and can be found by run time automatically.

JavaScript

Although JavaScript is classified as object-oriented language, only functions in root level in the file are modularized. Within the function, while it is sequential, nested functions are not fully modularized. It means within the function, your nested functions need to be placed in right order before it can be called. Even in root level, variablized functions still need to be treated carefully with the order. In particular, some built-in functions are very sensitive to the sequence, such as setTimeout() and setInterval().


http://en.wikipedia.org/wiki/Modular_programming
http://en.wikipedia.org/wiki/Javascript
http://koncordpartners.blogspot.com/2010/04/function-declaration-in-javascript.html

Labels