0% found this document useful (0 votes)
5 views3 pages

SQL Query for Order Updates and Joins

The document outlines a SQL query that retrieves order details from a database, specifically targeting operations named 'Slurry In' with certain conditions on start times and supply attributes. It includes multiple left joins to gather related supply information while filtering out specific orders based on attributes. Additionally, there are instructions to clear and update specific string values and adjust timings for certain operations.

Uploaded by

kun h
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views3 pages

SQL Query for Order Updates and Joins

The document outlines a SQL query that retrieves order details from a database, specifically targeting operations named 'Slurry In' with certain conditions on start times and supply attributes. It includes multiple left joins to gather related supply information while filtering out specific orders based on attributes. Additionally, there are instructions to clear and update specific string values and adjust timings for certain operations.

Uploaded by

kun h
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Clear string3 to be null

Update string3 same start time

Update string3 diff 1hr

Repeg after schedule rule

Update string4 diff 2 hr


SELECT Ord.[OrderNo],

Ord.[Priority],

Ord.[OpNo],

Ord.[OperationName],

Ord.[StartTime],

Ord.[EndTime],

Ord.[Hold],

Ord.[DatasetId],

Ord.[PartNo],

Ord.[Product],

Ord.[OperationProgress],

Ord.[LockOperation],

Ord.[Quantity],

[Link] as Supply_orderno,

[Link],

sup.StringAttribute1,

sup.StringAttribute2

,[Link]

,SUP2.StringAttribute1

,SUP3.StringAttribute2

FROM [SQS_Demo].[UserData].[Orders] AS Ord

Left Join [SQS_Demo].[UserData].[Supply] as Sup

on [Link] = 15

and (([Link] - [Link])='1900-01-01 02:00:00.000')

Left Join [SQS_Demo].[dbo].[Supply_Full_Used_21_ton] as SF


on [Link] = [Link]

Left Join [SQS_Demo].[UserData].[Supply] as Sup2

on [Link] = 15

and Ord.[OrderNo]=SUP2.StringAttribute1

and [Link] = [Link]

Left Join [SQS_Demo].[UserData].[Supply] as Sup3

on [Link] = 15

and Ord.[OrderNo]=Sup3.StringAttribute2

and [Link] = [Link]

WHERE Ord.[DatasetId] = 15

AND Ord.[StartTime] IS NOT NULL

AND Ord.[OperationName] = 'Slurry In'

and [Link] = 15

and sup.StringAttribute1 <> Ord.[OrderNo]

and sup.StringAttribute2 <> Ord.[OrderNo]

--and Sup.StringAttribute2<>''

and Sup.StringAttribute3=''

and (([Link] - [Link])='1900-01-01 02:00:00.000')

and [Link] is null

and SUP2.StringAttribute1 is null

and SUP3.StringAttribute2 is null;

You might also like