b-b-a / bba-power

1 stars 0 forks source link

Meters to add to a contract #183

Closed ghost closed 12 years ago

ghost commented 12 years ago

SQL to give the meters available for a contract in EMail. Takes under 0.02 of a second for most of the big customer on the BBA machine.

I would like the table to start with the current meters already ticked and then have the available meters following in the order given by the code.

ghost commented 12 years ago

Looking good but I missed tables look up for meter_status, contract_type & contract_status.

add to Select part: contract_status_table.tables_value as contract_status_value, contract_type_table.tables_value as contract_type_value, meter_status_table.tables_value as meter_status_value, add to left joins: left join tables AS contract_type_table on tables_name = "contract_type" AND tables_key = contract_type left join tables AS meter_status_table on tables_name = "meter_status" AND tables_key = meter_status

Gives extra fields of contract_status_value, contract_type_value, meter_status_value. (I have not tested this!)