-----select 后面是要查询的字段, t1.FDate AS '日期' 这种是给t1.FDate列起的别名
SELECT t1.FDate AS '日期',
t1.FBillNo as '单据号码',
t3.FShortNumber AS '物料代码',
t3.FName AS '物料名称',
t3.FModel AS '规格型号',
t4.FName AS '单位',
-- case when then else 这是判断,当t1.FTranType的值在 (1,2,5,10,40)里,取字段值 否则就是0
CASE WHEN t1.FTranType in (1,2,5,10,40) THEN t2.FQty ELSE 0 END AS '收入数量',
CASE WHEN t1.FTranType in (1,2,5,10,40) THEN t2.FAmount ELSE 0 END AS '收入金额',
CASE WHEN t1.FTranType in (1,2,5,10,40) THEN t2.FQty ELSE 0 END AS '发出数量',
CASE WHEN t1.FTranType in (1,2,5,10,40) THEN t2.FQty ELSE 0 END AS '发出金额',
t3.FQtyDecimal AS '数量精度',
t3.FPriceDecimal AS '单价精度'
---from 后是 查询涉及到的表
FROM ICStockBill t1,ICStockBillentry t2,t_ICItem t3,t_MeasureUnit t4
---where后是连接t条件及查询限制条件
WHERE t1.FInterID=t2.FInterID
AND t2.FItemID=t3.FItemID
AND t4.FItemID=t3.FUnitID
AND t4.FStandard=1
AND t1.FDate>='********'
and t1.FDate<='########'