我如何在哪里总结价格 [英] How Can I Sum The Price In Where Clause
问题描述
大家好,这是我的问题:
例如:
用户输入:2000为预期预算
用户选择婚礼为所需服务类型
以下是我数据库中的数据
ID服务类型价格
1婚礼500
2婚礼700
3婚礼1000
4婚礼300
5婚礼1000
这将是结果
4婚礼300
2婚礼700
3婚礼1000
或
3婚礼1000
5婚礼1000
< blockquote>您打算解决的问题称为线性编程。一个简单的形式,但仍然。
一般来说,LP不在任何数据库引擎的范围内。 Solver可以在Excel中为您完成此操作,但当然您可以使用独立的程序和库。当然,如果您知道算法,您可以使用一个或另一个RDBMS对其进行编程(请查看以下注意事项:https://www.simple-talk.com/sql/t-sql-programming/matrix-math-in-sql/ [ ^ ])。 Google为alxitm的单纯形法。
Hi Guys this is my problem:
for example:
User inputed: 2000 as desired budget
User selected Wedding as desired service type
Here are the data in my database
ID Service type Price
1 Wedding 500
2 Wedding 700
3 Wedding 1000
4 Wedding 300
5 Wedding 1000
This is what will be the result
either
4 Wedding 300
2 Wedding 700
3 Wedding 1000
Or
3 Wedding 1000
5 Wedding 1000
What you intend to solve is called linear programming. A simple form of it, but still.
In general LP is not in the scope of any database engine. Solver can do this for you in Excel, but of course there are standalone programs and libraries you can use. Of course if you know the algoritm, you might be able to program it using one or the other RDBMS (check these considerations: https://www.simple-talk.com/sql/t-sql-programming/matrix-math-in-sql/[^]). Google for "simplex method" for the algoritm.
这篇关于我如何在哪里总结价格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!