AXISHK
asked on
SQL Statement
I'm reviewing a SQL statement written by the vendor, can I simplify the two statements into one or there is some reason behind to separate into two line ? Tks
"inner join ROUTEOPRTABLE as c"
"inner join ROUTEOPRTABLE as d"
update BI_SALESDATA set FDATETIME = b.SUBMITDATE
from BI_SALESDATA as a
inner join ProdRouteInTransitTable as b
on a.PRODTABLE_PRODID = b.PRODID
inner join ROUTEOPRTABLE as c
on b.TOOPRID = c.OPRID
and c.OPERATIONGROUP ='P'
inner join ROUTEOPRTABLE as d
on b.FROMOPRID = d.OPRID
and d.OPERATIONGROUP ='F';
"inner join ROUTEOPRTABLE as c"
"inner join ROUTEOPRTABLE as d"
update BI_SALESDATA set FDATETIME = b.SUBMITDATE
from BI_SALESDATA as a
inner join ProdRouteInTransitTable as b
on a.PRODTABLE_PRODID = b.PRODID
inner join ROUTEOPRTABLE as c
on b.TOOPRID = c.OPRID
and c.OPERATIONGROUP ='P'
inner join ROUTEOPRTABLE as d
on b.FROMOPRID = d.OPRID
and d.OPERATIONGROUP ='F';
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
NO...
the pathways to [OPERATIONGROUP]
are through:
b.TOOPRID = c.OPRID
b.FROMOPRID = d.OPRID
the pathways to [OPERATIONGROUP]
are through:
b.TOOPRID = c.OPRID
b.FROMOPRID = d.OPRID
Actually I just deleted my own comment, I thought I may have found an equivalent using just one (more complex) join to that table, but it wasn't right.
Discuss that query with the vendor if you are that concerned about it.
Discuss that query with the vendor if you are that concerned about it.
I wouldn't touch this query without knowing the logic behind it.
Why are you concerned about it? It's running slow?
Why are you concerned about it? It's running slow?
It's somewhat speculative to say, without data and table structures, but it appears that the query is simply updating a date value in table A with the submission date from table B where a submission was made to a specific group ('P') on that date or from a specific group ('F') on that date.
ASKER
inner join ROUTEOPRTABLE as c
on b.TOOPRID = c.OPRID
and c.OPERATIONGROUP in ('P', 'F')