Sunday, May 2, 2010

My little database

The following is a query that delivers, approximately, the BLS series code need for a user define series. The stuff inn single quotes are simple aliases, using common names to get at the major series group. Like: Consumers Expenditure All All All

Would get you the BLS code for reported consumer expenses, all items, all income, all demographic. Then I just plug than into a select into the direct data, and ppe that to R, where I plot and work it. So one ends up with a simple SQL system with aliases to simplify indexing into myriads of data. Complicated macros, but few of them using native language terms.

select
s.supersector_name,s.supersector_code,
p.prefix_name, p.prefix_code,
ic.industry_name,ic.industry_code,
prod.item_name, prod.item_code,
d.datatype_text,d.datatype_code
from
supersector as s join prefixcodes as p
join industrycodes as ic join itemcodes as prod
join datatype as d
where s.token ='Raws'
and p.prefix_code = 'PC'
and ic.token = 'Raws'
and prod.token = 'All'
and d.token = 'Payrolls';

No comments: