我尝试使用以下查询
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,所以PLZ不介意
答案 0 :(得分:0)
我认为你正在寻找这个:
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
答案 1 :(得分:0)
这是一种方法:
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
如果我们正确地理解你,你想得到成本和scost的总和吗?
同样在SQL中,你的名字中不能有空格:如果你必须使用空格,拼盘顺序应该是拼盘顺序或[拼盘顺序]。