谁帮忙解释下这段SQL语句select\x05\x05 合同编号=p6.NO,\x05\x05 供货单位=p9.Name,\x05\x05 运输单位=p10.Name,\x05\x05 p3.StuffName as 原料购销名称,\x05\x05 原料样式=p5.StyleName,\x05\x05 车牌号码=p2.carcaption,\x05\x0

来源:学生作业帮助网 编辑:作业帮 时间:2024/05/05 07:11:32
谁帮忙解释下这段SQL语句select\x05\x05 合同编号=p6.NO,\x05\x05 供货单位=p9.Name,\x05\x05 运输单位=p10.Name,\x05\x05 p3.StuffName as 原料购销名称,\x05\x05 原料样式=p5.StyleName,\x05\x05 车牌号码=p2.carcaption,\x05\x0

谁帮忙解释下这段SQL语句select\x05\x05 合同编号=p6.NO,\x05\x05 供货单位=p9.Name,\x05\x05 运输单位=p10.Name,\x05\x05 p3.StuffName as 原料购销名称,\x05\x05 原料样式=p5.StyleName,\x05\x05 车牌号码=p2.carcaption,\x05\x0
谁帮忙解释下这段SQL语句
select
\x05\x05 合同编号=p6.NO,
\x05\x05 供货单位=p9.Name,
\x05\x05 运输单位=p10.Name,
\x05\x05 p3.StuffName as 原料购销名称,
\x05\x05 原料样式=p5.StyleName,
\x05\x05 车牌号码=p2.carcaption,
\x05\x05 运输车次=count(p1.ID),
\x05\x05 入库吨数=SUM(p1.NetNum),
\x05\x05 对方吨数=sum(p1.SellerNum),
\x05\x05 原料单价=p1.StuffPrice,
\x05\x05 原料金额=sum(p1.StuffMoney),
\x05\x05 运输单价=p1.TransitPrice,
\x05\x05 运输金额=sum(p1.TransitMoney),
\x05\x05 总金额=sum(p1.StuffMoney+p1.TransitMoney),
\x05\x05 p5.StyleNameE as 规格,
\x05\x05 p4.Name as 原料名称,
\x05\x05 ROW_NUMBER() OVER(order by p5.StyleName asc ) as Rowno
\x05\x05 from stuffWeighinout as p1
\x05\x05 inner join stuffweighin as p2 on p1.stuffweighin_ID=p2.ID
\x05\x05 left join StuffGodown as p13 on p13.ID=p2.StuffGodown_ID
\x05\x05 inner join stuffContractProduct as p3 on p3.ID=p2.stuffContractProduct_ID
\x05\x05 inner join stufffactoryproduct as p4 on p4.ID=p3.stufffactoryproduct_ID
\x05\x05 inner join productStyle as p5 on p5.ID=p4.productStyle_ID
\x05\x05 inner join productType as p11 on p11.ID=p5.productType_ID
\x05\x05 inner join StuffContract as p6 on p6.ID=p3.StuffContract_ID
\x05\x05 inner join sellunit as p7 on p7.ID=p4.Sellunit_ID
\x05\x05 inner join sellunit as p9 on p9.ID=p6.SellUnit_BID
\x05\x05 inner join sellunit as p10 on p10.ID=p6.SellUnit_CID
\x05\x05 inner join NumUnit as p12 on p12.ID=p4.NumUnit_ID
\x05\x05\x05\x05 where 1=1 and p1.OutSetTime >'2014/4/23 8:00:00'
\x05\x05 and '2014/4/24 8:00:00'>=p1.OutSetTime and p2.StuffWeighInOut_ID is null
\x05
\x05\x05 group by p5.StyleName,p4.Name,p5.StyleNameE,p9.Name,p10.Name,p2.carcaption,p1.TransitPrice,p1.StuffPrice,p6.NO,p3.StuffName
\x05\x05 order by p10.Name,p5.StyleName,p2.carcaption,p9.Name

谁帮忙解释下这段SQL语句select\x05\x05 合同编号=p6.NO,\x05\x05 供货单位=p9.Name,\x05\x05 运输单位=p10.Name,\x05\x05 p3.StuffName as 原料购销名称,\x05\x05 原料样式=p5.StyleName,\x05\x05 车牌号码=p2.carcaption,\x05\x0
select--下面是显示的列
合同编号=p6.NO,
供货单位=p9.Name,
运输单位=p10.Name,
p3.StuffName as 原料购销名称,
原料样式=p5.StyleName,
车牌号码=p2.carcaption,
运输车次=count(p1.ID),
入库吨数=SUM(p1.NetNum),
对方吨数=sum(p1.SellerNum),
原料单价=p1.StuffPrice,
原料金额=sum(p1.StuffMoney),
运输单价=p1.TransitPrice,
运输金额=sum(p1.TransitMoney),
总金额=sum(p1.StuffMoney+p1.TransitMoney),
p5.StyleNameE as 规格,
p4.Name as 原料名称,
ROW_NUMBER() OVER(order by p5.StyleName asc ) as Rowno--新编号
from --下面是查询的表
stuffWeighinout as p1
inner join stuffweighin as p2 on p1.stuffweighin_ID=p2.ID--内关联,和两个表之间的关联关系
left join StuffGodown as p13 on p13.ID=p2.StuffGodown_ID--左关联,和两个表之间的关联关系
inner join stuffContractProduct as p3 on p3.ID=p2.stuffContractProduct_ID
inner join stufffactoryproduct as p4 on p4.ID=p3.stufffactoryproduct_ID
inner join productStyle as p5 on p5.ID=p4.productStyle_ID
inner join productType as p11 on p11.ID=p5.productType_ID
inner join StuffContract as p6 on p6.ID=p3.StuffContract_ID
inner join sellunit as p7 on p7.ID=p4.Sellunit_ID
inner join sellunit as p9 on p9.ID=p6.SellUnit_BID
inner join sellunit as p10 on p10.ID=p6.SellUnit_CID
inner join NumUnit as p12 on p12.ID=p4.NumUnit_ID
where
1=1 --此条件无意义
and p1.OutSetTime >'2014/4/23 8:00:00'--OutSetTime>'2014/4/23 8:00:00'这个时间
and '2014/4/24 8:00:00'>=p1.OutSetTime --'2014/4/24 8:00:00'>=p1.OutSetTime
and p2.StuffWeighInOut_ID is null--StuffWeighInOut_ID is nul=p2没有关联的到数据
group by--分组条件
p5.StyleName, p4.Name,p5.StyleNameE,p9.Name,p10.Name,p2.carcaption,p1.TransitPrice,p1.StuffPrice,p6.NO,p3.StuffName
order by --排序条件
p10.Name,p5.StyleName,p2.carcaption,p9.Name