帮我看下SQL语句错在哪里select a.comid as 货号,a.barcode as 条码,sum(b.stock_qty) as 总库存,sum(c.sale_qnty) as 总销售fromtemp01 a left join bwsyv9_01.dbo.ic_t_branch_stock b on(a.item_no = b.item_no ) left join bwsyv9_01.dbo.pos_t

来源:学生作业帮助网 编辑:六六作业网 时间:2024/11/17 23:36:05
帮我看下SQL语句错在哪里selecta.comidas货号,a.barcodeas条码,sum(b.stock_qty)as总库存,sum(c.sale_qnty)as总销售fromtemp01al

帮我看下SQL语句错在哪里select a.comid as 货号,a.barcode as 条码,sum(b.stock_qty) as 总库存,sum(c.sale_qnty) as 总销售fromtemp01 a left join bwsyv9_01.dbo.ic_t_branch_stock b on(a.item_no = b.item_no ) left join bwsyv9_01.dbo.pos_t
帮我看下SQL语句错在哪里
select a.comid as 货号,a.barcode as 条码,sum(b.stock_qty) as 总库存,sum(c.sale_qnty) as 总销售
from
temp01 a left join bwsyv9_01.dbo.ic_t_branch_stock b on(a.item_no = b.item_no ) left join bwsyv9_01.dbo.pos_t_saleflow c on(a.item_no = c.item_no)
where
a.yesno ='0'
group by
a.comid,a.barcode
select a.comid as 货号,a.barcode as 条码,sum(b.stock_qty) as 总库存数,sum(c.sale_qnty) as 总销售
from
temp01 a,bwsyv9_01.dbo.pos_t_saleflow c,bwsyv9_01.dbo.ic_t_branch_stock b
where
(a.item_no = c.item_no and a.item_no = b.item_no) and a.yesno ='0'
group by
a.comid,a.barcode
这两个语句都有同样一个错误 SUM()函数内统计的数量完全不正确
我用商品资料表同时结联了一个库存与一个销售表 之后查出来就不正确了(SUM统计的库存与销售都是多倍的)
如果我只用一个JOIN(结联一个表)就不会出现这种问题
帮我看下错在哪里?

帮我看下SQL语句错在哪里select a.comid as 货号,a.barcode as 条码,sum(b.stock_qty) as 总库存,sum(c.sale_qnty) as 总销售fromtemp01 a left join bwsyv9_01.dbo.ic_t_branch_stock b on(a.item_no = b.item_no ) left join bwsyv9_01.dbo.pos_t

以你第一个为例,主要是你在销售和库存中有多条同一个item_no的记录,所以造成笛卡尔积

 

第一个这样

select a.comid as 货号,a.barcode as 条码,b.总库存,c.总销售 
from temp01 left join
(select item_no,sum(stock_qty) as 总库存 from bwsyv9_01.dbo.ic_t_branch_stock group by item_no) b
on a.item_no = b.item_no 
left join 
(select item_no,sum(sale_qnty) as 总销售 from  bwsyv9_01.dbo.pos_t_saleflow group by item_no) c
on a.item_no = c.item_no 
where a.yesno ='0'

你第二个应该也是类似问题

帮我看下SQL语句错在哪里select a.comid as 货号,a.barcode as 条码,sum(b.stock_qty) as 总库存,sum(c.sale_qnty) as 总销售fromtemp01 a left join bwsyv9_01.dbo.ic_t_branch_stock b on(a.item_no = b.item_no ) left join bwsyv9_01.dbo.pos_t VB 里...谁帮我看看这一句语句错在哪里了?sql = select [明细序号],[存款金额] from [cardinlist] where [账户号码] = & Trim(combcard.Text) & and [日期] between # + fird + # and # + secd + #总是不对.. SQL 语句 SELECT * FROM {{table}} WHERE `fleet_end_time` 在SQL语句中USE pubs SELECT DISTINCT title FROM title WHERE price>(SELECT MIN(price)FROM titleGROUP BY typeHAVING type='trad_cook')本人是初学者,请大家帮我解释每句的意思,讲解一下这种语句的语法结构, sql如何取交集有这样两条sql语句select distinct id from a where id='123'select distinct id from a where id='456'我希望能把他们取得他们记录的交集,sql语句该如何写?错了 应该是这样的select distinct temid from a whe sql语句,求大神看看我这句话哪里有错!select * from ( select FUNCTIONAL_LOCATION,HDR_END_DATE,row_number()over(partition by FUNCTIONAL_LOCATION order by HDR_END_DATE ) mm from T_EODB_CONTRACT_ITM_DEL) where mm=1; 在SELECT-SQL语句的ORDER BY子句中,DESC表示按什么输出 这个到底错在哪语句未结束 sql=select * from orderform where issuedate between dateadd(m,-3,now()) and now()-----------------------------------------------------------------------------------^我要读取某access数据表中的近三 大神帮我看下我哪里错了. 第五第六第七题帮我看下哪些错了 错在哪里 请问大侠,我要在function()下写一个动态sql语句,如select * from A WHERE name in (‘b’,'c','d')但是b,c,d 是不定的,也就是我有可能传入两个参数,有可能一个参数,有可能三个参数.具体情况需要根 select id from (select * from tree)这个sql语句有什么错吗提示:Every derived table must have its own aliasmysql数据库 select count(*) from table1 select count(*) from table2 select count(*) from table3我从table1 table2 table3 中 找数据的条数怎样一下子用一条sql语句 算出TABLE1 TABLE2 TABLE3 记录的总和? 帮我解释一下这条sql语句的意思select month01.pk_deptdoc as dept,month01.amot as month01,month02.amot as month02from(select h.pk_deptdoc,sum(expense_amot) as amot from te_expense_b b left join te_expense h on b.pk_expense=h.pk_expensewhere 我想问下这个SQL语句哪里出了问题啊? 我想问下一句查询最大值与最小值的sql语句我是这么写的但是会报错select min(price),max(price)from 表 where price>190price比如是1-10000,我的目标是查询之后显示出的事大于190的并且在旁边显示PRI string sql = select * from user where user_name=' +t1.Text.Trim()+ ' and user_password='+t2.Texstring sql = select * from user where user_name=' +t1.Text.Trim()+ ' and user_password='+t2.Text.Trim()+ ';错在哪里啊?protected void Button1 sql is not null 怎么会把空的数据也查出来今天做个项目,有一个要求就是在 industry_po 表里把BAK1(varchar类型)字段不为空的数据给查出来,我写了sql语句为:select * from industry_po where bak1 is not null