Home > database >  Federated query based on a single field in a SQL server to heavy
Federated query based on a single field in a SQL server to heavy

Time:10-28

federated query in SQL server how to heavy, according to a field to heavy just according to the sparepart. Id to heavy
Select
sparepart. Id, sparepart. SnNumber, sparepart. SpNumber, sparepart. WarehousingId, sparepart. OutWarehousingId, sparepart. EquipmentId, sparepart. ParentId, sparepart. InTime, sparepart. OutTime, sparepart. Remark,
Sparepart. SupplierId, sparepart. IsMachine sparepart. Status, sparepart. Abnormal, sparepart. GoodOrBad, sparepart. WarrantyStartDate, sparepart. WarrantyEndDate,
Sparepart. WareHouseId, sparepart. WwNumber sparepart. CtNumber, sparepart. CreateUserId, sparepart. CreateTime, sparepart. InUserId, sparepart. OutUserId,
Sparepart. WaybillNo sparepart. UseStatus sparepart. State, sparepart. ShelfLocation,
Equipment. Id equipment_id, equipment name equipment_name,
: supplier. Id supplier_id, : supplier name supplier_name,
Warehouse. Id warehouse_id, warehouse name warehouse_name,
Dbuser. Id, user_id, dbuser name user_name,
Outwarehousing. Id outwarehousing_id, outwarehousing wareHouseId outwarehousing_wareHouseId, outwarehousing. InWareHouseId outwarehousing_InWareHouseId
The from sparepart
Left the join equipment on sparepart. EquipmentId=equipment. Id
Left the join: supplier on sparepart. SupplierId=: supplier. Id
Left the join warehouse on sparepart. WareHouseId=warehouse. Id
Left the join outwarehousesparepart on outwarehousesparepart. SparePartId=sparepart. Id
Left the join dbo. [user] dbuser on dbuser. Id=sparepart. CreateUserId
Left the join outwarehousing on outwarehousing. Id=sparepart. OutwarehousingId
Where sparepart. Status=0

CodePudding user response:

To at least two elements,
A packet fields, here you have the sparepart. Id
The second is the duplicate records, according to the rules to choose? The you don't have decided

CodePudding user response:

 
-- -- -- -- -- - the problem description is not clear, can't give a specific implementation code,
SELECT Distinct sparepart. Id FROM sparepart


CodePudding user response:

Right to heavy must have one or more repeat these repeated field is also your terms of grouping
Also have a data filter field, which is to decide which ones which left or delete to heavier does not make sense

CodePudding user response:

 
The CREATE TABLE # T (ID INT IDENTITY, RQ DATE, SL INT)
INSERT INTO # T (RQ, SL)
VALUES (' 2019-01-01 ', 1),
(' 2019-01-03 ', 3),
(' 2019-01-04 ', 1),
(' 2019-01-05 ', - 3),
(' 2019-01-07 ', 1);
WITH CTE AS (
SELECT ID, RQ, SL, HJ=SL FROM # T WHERE ID=1
UNION ALL
The SELECT T.I D, T.R Q, T.S L, HJ=T.S L + CTE. HJ FROM # T T INNER JOIN CTE ON T.I D=CTE. ID + 1)
SELECT * FROM CTE
DROP TABLE # T

CodePudding user response:

Study hard, to see see!
  • Related