我尝试使用以下查询
Select cost + scost from
(Select count(order no) as cost
From platter order where cost= cost*25*discountpercent) ,
(Select count(order no)as scost from schoolorder
Where scost=scost*25);
我正在学习 SQL,所以请不要介意
我尝试使用以下查询
Select cost + scost from
(Select count(order no) as cost
From platter order where cost= cost*25*discountpercent) ,
(Select count(order no)as scost from schoolorder
Where scost=scost*25);
我正在学习 SQL,所以请不要介意
这是一种方法:
Create table #temp (cost as decimal(1,2), scost as decimal(1,2))
INSERT INTO #temp
(Select count(order no) as cost From platter order where cost= cost*25*discountpercent) ,
(Select count(order no)as scost from schoolorder
Where scost=scost*25);
Select cost + scost from #temp
如果我们对您的理解正确,您想获得成本和成本的总和吗?
同样在 SQL 中,您的名称中不能有空格:如果必须使用空格,则拼盘顺序应为拼盘顺序或 [拼盘顺序]。
我想你正在寻找这个:
SELECT
(cost + scost) as Total_Cost,
((cost + scost) * 25 * discountpercent) as Discounted_Cost,
count(order_number) as Order_Count
FROM
schoolorder
WHERE
scost = scost * 25