本文介绍了列乘以select语句MSSQL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Need multiply two column with select statement MSSQL
错误是列数量2不存在
我的尝试:
Error is column quantity2 not exist
What I have tried:
INSERT INTO dbo.table1 (quantity1, quantity2, result)
SELECT quantity1,
(select kolicina as quantity2 from dbo.radni_nalog_roba where id_fakture=(select max(id) from dbo.radni_nalog_lista)),
(quantuty1*quantity2) as ukupno
FROM dbo.table2
推荐答案
SELECT a.quantity1, b.quantity2 , (a.quantuty1 * b.quantity2) AS ukupno
FROM dbo.table2 a
JOIN (SELECT kolicina AS quantity2 FROM dbo.radni_nalog_roba
WHERE id_fakture = (SELECT MAX(id) FROM dbo.radni_nalog_lista)) b
ON a.ID = b.id_fakture
或类似。
这篇关于列乘以select语句MSSQL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!