У меня проблемы с преобразованием этого скрипта для использования в BIRT
.
. Это работает, когда я не использую DATEPART(Week,[week])
, но я хотел бы использовать его, чтобы показать номер недели. Последние 3 команды AND вызывают ошибку сейчас, и я не понимаю, почему. Может кто-нибудь, пожалуйста, посоветуйте, так как я все еще довольно новичок в SQL.
SELECT stocktransactions.type,
stocktransactions.createddate,
stocktransactions.referencedate AS tradate,
Datepart(week,[week]) AS week,
stocktransactions.partid,
stocktransactions.partrevisionid,
stocktransactions.quantity,
stocktransactions.locationid,
stocktransactions.reference,
stocktransactions.source,
stocktransactions.stockvalue,
stocktransactions.batchnumber,
stocktransactions.warehouseid,
stocktransactions.stocktaketicket,
stocktransactions.worksorderid,
stocktransactions.createdby,
stocktransactions.physicalstockquantity,
stocktransactions.origin,
allpartmaster.partdesc,
allpartmaster.prodgroup,
stockbatches.serialnumber,
stockbatches.batchid,
stockbatches.classification,
CASE
WHEN warehouses.traderid IS NOT NULL
when warehouses.traderid
ELSE stockbatches.traderid
END AS generaltraderid,
traders.NAME
FROM stocktransactions
LEFT OUTER JOIN stockedparts
ON stocktransactions.partid = stockedparts.partid
INNER JOIN allpartmaster
ON allpartmaster.partnum = stocktransactions.partid
LEFT OUTER JOIN stockbatches
ON stocktransactions.batchnumber = stockbatches.batchnumber
LEFT OUTER JOIN warehouses
ON stockbatches.warehouseid = warehouses.warehouseid
LEFT OUTER JOIN traders
ON (
warehouses.traderid = traders.id
AND warehouses.tradertype = traders.tradertype)
OR (
stockbatches.traderid = traders.id
OR stockbatches.tradertype = traders.tradertype)
WHERE traders.id LIKE '%'
AND stocktransactions.partid LIKE '%'
AND stocktransactions.warehouseid LIKE '%'
AND stocktransactions.reference LIKE '%'
AND stocktransactions.source LIKE '%'
AND stocktransactions.worksorderid LIKE '%'
AND stocktransactions.type LIKE '%'
AND stockbatches.serialnumber LIKE '%'
AND allpartmaster.prodgroup LIKE '%'
AND stocktransactions.batchnumber LIKE '%'
AND stockbatches.batchid LIKE '%'
AND stockbatches.classification LIKE '% AND stocktransactions.origin LIKE '%' AND stocktransactions.locationid LIKE '%' AND ((stockbatches.consignmenttype IS NOT NULL AND stockbatches.consignmenttype LIKE '%') OR ('%' = 1 AND stockbatches.consignmenttype IS NULL)) AND ('%' = 0 OR (warehouses.isconsignment IS NOT NULL AND warehouses.isconsignment = 1)) AND stocktransactions.referencedate = '%' AND stocktransactions.createddate = '%'