How in SQL could you “zip” together records in separate tables (à la the UNIX paste(1) utility)?
For example, assuming two tables, A and B, like so:
A B
======== ====
Harkness unu
Costello du
Sato tri
Harper
Jones
How could you produce a single result set
NAME | NUM
===============
Harkness | unu
Costello | du
Sato | tri
Harper | NULL
Jones | NULL
?
In
SQL Server 2005,Oracle 9iandPostgreSQL 8.4and higher:Note that
ROW_NUMBER()requires that the records are explicitly sorted.If you don’t have a column similar to
id, you cannot sort the records in order other than alphabetical, since relational databases have no concept of implicit record order.