Everyone should learn the difference between Union and Union All. Knowing it will make you a better programmer, and it’s fairly trivial to understand.
SELECT * FROM apples
UNION
SELECT * FROM oranges
When you know for a fact that there will never be any common rows between the apples table and the oranges table, this query will be [...]
Tuesday, January 19th, 2010
In SAS DI Studio 3.4 (and I imagine in future versions), the prepackaged code for the SCD Type-2 Loader works like this: Does the dataset exist? If not, create an empty dataset with structure and indexes as defined from metadata. Then detect differences between it and the source dataset and the target dataset, expire any [...]
Wednesday, March 18th, 2009
This is among many brilliant hacks from this page.
b = (b * 0×0202020202ULL & 0×010884422010ULL) % 1023;
The multiply operation creates five separate copies of the 8-bit byte pattern to fan-out into a 64-bit value. The AND operation selects the bits that are in the correct (reversed) positions, relative to each 10-bit groups of bits. The [...]
Tuesday, September 16th, 2008
If your SQL code has a nested select that references a column in an outer select, such as the following, it may be possible to rewrite to perform orders of magnitude faster.
proc sql;
create table new_rates as
select
from work.exchange_rate n
where not [...]