ICD-9 code is known:
Use this query to lookup the _C_BASECODE_ and _C_FULLNAME_ for ICD-9 diagnosis code 346.0
SELECT C_BASECODE, C_FULLNAME
FROM RPDR
WHERE C_BASECODE = '3460'
The _C_BASECODE_ returned in the results can then be joined to the CONCEPT_CD in the OBSERVATION_FACT table to find all patients diagnosed with ICD-9 code 346.0. Note that the C_BASECODE 3460 has no decimal point, these are removed.

ICD-9 code is unknown, but the diagnosis description is known:
Use this query to lookup the _C_BASECODE_ and _C_FULLNAME_ for the diagnosis of migraines.
SELECT C_BASECODE, C_FULLNAME
FROM RPDR
WHERE C_FULLNAME like '%diagnoses%migraine%'
The C_BASECODEs returned in the results could then be joined to the CONCEPT_CD in the OBSERVATION_FACT table to find all patients diagnosed with migraines.