Welcome Guest, Not a member yet? Register   Sign In
Active record order_by the result of multiplying two fields
#9

Thanks Bill. There seems to be a delay in my replies getting posted. I can't use just price min because the prices are in different currencies. 200,000 USD is more expensive than 50,000,000 Pesos. It's working now though... See me previous post above. Thanks for pointing me in the right direction though! Give my regards to Hillary Wink

(11-18-2014, 06:33 PM)bclinton Wrote:
(11-18-2014, 05:22 PM)andycansdale Wrote: I like your idea of running the calculation in the select and then ordering on the new named field. It would be a nice clean way to do it. Perhaps you know how I could get this to work with select_min, which when translated into SQL already has the 'as [field_name]' included. This is the value that needs to be multiplied by the rate.




Code:
$this->db->select_min("project_units.price_min")
becomes



Code:
MIN(`project_units`.`price_min`) AS price_min

can't you just use price_min? 

Also, you don't necessary have to use select_min, you could use


PHP Code:
$this->db->select("MIN(`project_units`.`price_min`) AS whatever_you_want_to_call_it"
Reply


Messages In This Thread
RE: Active record order_by the result of multiplying two fields - by andycansdale - 11-18-2014, 06:39 PM



Theme © iAndrew 2016 - Forum software by © MyBB