①:部門資訊表 bm ,要求列名有:bmid(部門ID:字符型(主鍵)),bmmc(部門名稱:字符型);
Bmid Bmmc
1 內科
2 外科
②:物品資訊表 cp,要求列名有:cpxh(物品ID:數值型(主鍵)),cpmc(物品名稱:字符型),cpgg(規格:字符型),jj(進價:數值型);
Cpxh cpmc Cpgg JJ
1 列印機 EPSON-300 3450
2 計算機 HP500 3500
③:庫存表 cc, 列名有: bmid(部門ID:字符型), cpxh(物品ID:數值型),kcsl(數量:數值型);
Bmid Cpxh Kcsl
w2 1 5
1 2 7
5 3 3
3 1 5
使用SQL陳述句找出[庫存表]中進價總額最高的物品;
求大神 急
uj5u.com熱心網友回復:
select top 1 * from(select cp.cpmc,cp.cpgg,cc.cpxh,cc.kcsl,cp.jj,cc.kcsl * cp.jj as 總金額 from cc left join cp on cp.cpxh = cc.cpxh)a order by 總金額 desc
試下看看能行不
uj5u.com熱心網友回復:
用excel 畫下結果。uj5u.com熱心網友回復:
select top 1 * from(select cp.cpmc,cp.cpgg,cc.cpxh,cc.kcsl,cp.jj,cc.kcsl * cp.jj as 總金額 from cc left join cp on cp.cpxh = cc.cpxh)a order by 總金額 desc
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/29782.html
標籤:基礎和管理
