在下面的查询中,我只是获取项目详细信息及其数量和速率(根据某些业务逻辑计算的数量和速率,以便使用子查询或聚合)。
SELECT ItemID, ItemName, (... ... ) AS ItemQty, (.... .... ) AS ItemPrice FROM ....现在我需要在Amount (即ItemQty * ItemPrice )的网格中列出这些细节。
Sample Output ------ ItemId ItemName ItemQty ItemPrice Amount 1 ABC 10.0 22.5 225.0 2 PQR 12.35 156.5 1932.775我有两个选项来计算Amount ( ItemQty * ItemPrice )
计算sql查询本身的数量
再次使用整个子查询来乘以值或外部选择查询来计算相同
使用UI /代码部分计算ItemQty * ItemPrice,同时将数据绑定到网格。在这个我可以遵循哪一个?
In the below query, i just fetch the Item details with its qty and rate (qty and rates ate calculated based on some business logic, so that using sub queries or aggregates).
SELECT ItemID, ItemName, (... ... ) AS ItemQty, (.... .... ) AS ItemPrice FROM ....Now i need to list this details in a grid with Amount (ie ItemQty * ItemPrice).
Sample Output ------ ItemId ItemName ItemQty ItemPrice Amount 1 ABC 10.0 22.5 225.0 2 PQR 12.35 156.5 1932.775I have two options to calculate Amount (ItemQty * ItemPrice)
Calculate the amount in sql query itself
using the entire sub queries again to multiply the values or an outer select query to calculate the same
use the UI/code part to calculate the ItemQty * ItemPrice while binding the data to grid.In this which one i can follow?
最满意答案
您应该通过在UI中进行逻辑来隔离逻辑。
SQL代码比C#代码更快吗?
此链接很好地解释了您的问题。
希望这可以帮助!
You should isolate the logic by doing it in UI.
Is SQL code faster than C# code?
This link explains well for your question.
Hope this helps!
更多推荐
发布评论