• 0 Posts
  • 2 Comments
Joined 1 year ago
cake
Cake day: June 14th, 2023

help-circle
  • That sounds kind of like putting business logic in your data layer. I generally try to avoid that but you could do something like

    SELECT ( :Doodads_amt * case when id=:doodad_id then price else 0 end ) + (:whatzits_amt * case when id=:whitzits_id then price else 0 end ) from components where component id in (:doodad_id, :whatzits_id);

    That’s probably not exactly it but you can work with the case statements to filter the data you need. I can’t remember off the top of my head what you want in your else statement

    The words with a colon at the front are bind variables.

    What might be easier is to just query for the price of each item then multiply that price by an amount in your API.

    Let me know if you have questions.