我有2张桌子
invm
和invt
invm
已
i_b_no , i_b_dt , freight , tot_amt
1001 , 04/01/2015, 805 , 5000
1002 , 04/01/2015, 205 , 300
invt
已
i_b_no , item_code, item_desc , stax_rate , amount
1001 , xyz , adlasjdlja, 12.5, 1000
1001 , abc , dfjsdffsdf, 12.5, 1000
1001 , lkm , sfkgsfksdn, 10.5, 1000
1001 , rmn , yeryoueoqe, 5.00, 1000
1001 , the , qwelskjfsdf, 12.5, 1000
1002 , dad , sdfkdsffsdf , 10.0, 100
1002 , dekw , kdasdahdafa , 3.2 , 100
1002 , dasdna , kdfnasldakdf, 6.8 , 100
现在我想要sum ( (freight) * max(staxrate) /100 )
是(805* 12.5)/100 = 1006.25
(205 * 10)/100 = 20.5
ans应为1026.75
我用过
select sum (( sum (INVM.FREIGHT ) * MAX (INVT.STAX_RATE) /100 ))
from invm inner join INVT on INVM.I_B_NO = INVT.I_B_NO
where
invm.i_b_dt between '04/01/2015 00:00:00' and '04/01/2015 00:00:00'
group by INVM.FREIGHT
给我错误
消息130,级别15,状态1,行1无法执行聚合 对包含聚合或子查询的表达式的函数
我被困在这请求帮助
答案 0 :(得分:2)
使用public static class RecyclerViewFragment extends Fragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View root = inflater.inflate(R.layout.fragment_recyclerview, container, false);
RecyclerView recyclerView = (RecyclerView) root.findViewById(R.id.recycler_view);
recyclerView.setHasFixedSize(true);
recyclerView.setItemAnimator(new DefaultItemAnimator());
recyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
recyclerView.addItemDecoration(new DividerItemDecoration(getActivity(), DividerItemDecoration.VERTICAL_LIST));
RecyclerViewAdapter adapter = new RecyclerViewAdapter(getActivity(), getResources()
.getStringArray(R.array.countries));
recyclerView.setAdapter(adapter);
return root;
}
}
和JOIN
执行派生表格中的GROUP BY
:
MAX