我是sql新手.我想总结来自不同领域的两列值 [英] i m new in sql. and i want to sum two columns value from different tabales

查看:87
本文介绍了我是sql新手.我想总结来自不同领域的两列值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个表stock和product_order.在第一个表中我有三列item_code,product_name,stock_on_hand,在第二个表中有product_name,product_quan,check_bit....我希望当check_bit的值更改为0到1时, stock_on_hand =(stock_on_hand + product_quan)....我应该怎么做

i have two table stock and product_order.in first table i having three columns item_code,product_name,stock_on_hand and in second table product_name,product_quan,check_bit.... i want that when the value of check_bit is change 0 to 1 then the stock_on_hand=(stock_on_hand+product_quan) ....what should i do

推荐答案

u应该这样尝试:
u should try like that :
select SUM(st.Prd_stock)Stock_Sum,SUM(prd.Prd_qnt)Product_Sum from stock st inner join prodcut prd on st.Prd_Name=prd.Prd_Name and prd.Prd_chk=1


选择SUM(stock_on_hand)+在stock.product_Name = product.product_Name和product.product_chk = 1
select SUM(stock_on_hand) + SUM(prd.Prd_product_quan)as total_stock from stock st inner join prodcut prd on stock.product_Name=product.product_Name and product.product_chk=1


这篇关于我是sql新手.我想总结来自不同领域的两列值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆