gjsaturday
Technical User
a query would be written this way...
SELECT (SELECT Code
FROM Location AS A
WHERE A.ID = Location.Parent) AS typecode,
(select CODE from type where Location.type=type.ID) as tCode,db
rderRecommendation.Amount, db
rderRecommendation.OrderDate,
db
rderRecommendation.ShipDate
FROM db
rderRecommendation
INNER JOIN dbo.Location ON db
rderRecommendation.ttID = dbo.Location.ID
WHERE DATEDIFF(dd, db
rderRecommendation.OrderDate, GETDATE()) = 0 AND (db
rderRecommendation.OrderType = 0)
when it can easily be accomplished this way...
select type.code, d.code, j.Amount, j.OrderDate, j.ShipDate
from
location t
inner join type d on t.type = d.id
inner join OrderRecommendation j on t.id = j.typetid and j.orderdate = convert(varchar,(getdate()),101)
inner join location type on t.parent = type.id
I don't know who wrote the first one to ask if there was a reason for writing it that way.
Thanks in advance.
SELECT (SELECT Code
FROM Location AS A
WHERE A.ID = Location.Parent) AS typecode,
(select CODE from type where Location.type=type.ID) as tCode,db
db
FROM db
INNER JOIN dbo.Location ON db
WHERE DATEDIFF(dd, db
when it can easily be accomplished this way...
select type.code, d.code, j.Amount, j.OrderDate, j.ShipDate
from
location t
inner join type d on t.type = d.id
inner join OrderRecommendation j on t.id = j.typetid and j.orderdate = convert(varchar,(getdate()),101)
inner join location type on t.parent = type.id
I don't know who wrote the first one to ask if there was a reason for writing it that way.
Thanks in advance.