The many uses of DBMS_RANDOM

DBA's are often faced with scenarios where they have to generate test data for developers. Let's say you have a test database with no values in a certain field. Using DBMS_RANDOM, you can just generate them on your own.
Example: Refer the table structure in my previous post. Let's say I don't have any values for Medication. My code values for Medication are 4 digits and range from 0001 to 0100.
These are some ways I would add data for these columns: Let's say I now need to set a few of them to '-1', which is the code for missing data. Here is a great way to do it:
Pick any random value from some other field and use it to assign values to this one. What if you had to generate all the data by yourself? It's not a big deal. Here are some tips:
Generate Time with AM/PM: Random date: One digit value with range: A random string with specific length: Generate a random end date when start date is provided: Date of birth to Age calculation:

Reverse crosstab query in Oracle

Most of us are familiar with cross-tabbing in queries. It's basically changing rows into columns. If you have a requirement to do the reverse, do the following: Let’s say this is the initial table structure: Let's say you need to change this into the following structure: (Columns into Rows) Here is the sql for reverse cross tabbing: This would be the result:
CID DATE_REPORTED MED_CODE MEDICATION REPORTING_PROVIDER SOURCE MEDICATION_TYPE
77518254 14.10.2009 0032 ARTANE(TRIHEXYPHENIDYL)(ANTI-CHOLINERGICS) 20 MICP MEDICATION 1
77518254 14.10.2009 0008 LUVOX(FLUVOXAMINE)(ANTI-DEPRESSANTS) 20 MICP MEDICATION 3
77518254 14.10.2009 0101 MARPLAN(ISOCARBOXAZID)(ANTI-DEPRESSANTS) 20 MICP MEDICATION 3
77518254 14.10.2009 0112 MARPLAN(ISOCARBOXAZID)(ANTI-DEPRESSANTS) 20 MICP MEDICATION 4