数据表中有原价MarketPrice和销售价SalePrice两个字段,如何使用二者计算出的折扣作为where语句中的筛选条件进行查询呢?数据表中没有折扣字段。
最直观的,比如要查折扣额为10元的
where MarketPrice-SalePrice = 10
或者下面这个也是等价的
where MarketPrice= 10+SalePrice
如果是要按折扣范围查
where MarketPrice-SalePrice between 1 and 100
表达式既可以作为查询字段,也可以作为条件字段哦
折扣率也是一个道理
where SalePrice/MarketPrice between 0.8 and 0.9
这东西加减乘除随你怎么玩