updated with a margin column. Depends on price data being loaded into the database, and an index.

create index blueprinttypes on invBlueprintTypes(productTypeid,blueprinttypeid);

price data is:
regionid,typeid,pricesell