0

Guys,

When i run this sscript i got an error in Where clause?
Where should be place this where clause?

SELECT p.ESN, p.ReturnDate,s.Receiptdate,e.Shipdate
FROM USProductRecovery p with (nolock)
OUTER APPLY((SELECT TOP 1 Receiptdate
FROM ESNSalvReceipts s with (nolock)
WHERE ESN = p.ESN
AND Receiptdate > p.Returndate
ORDER BY Receiptdate )s
OUTER APPLY(SELECT TOP 1 Shipdate
FROM dbo.ESNShip s with (nolock)
WHERE ESN = p.ESN
AND Shipdate > p.Returndate
ORDER BY Shipdate)e
Where p.returndate > '2012-11-01'
and p.ESN in ('268435459401659246','268435458814622954','270113179507864837')

Thanks,

JOV

2
Contributors
3
Replies
4
Views
5 Years
Discussion Span
Last Post by BitBlt
0

You have an extra open-parenthesis on line 3. Or, depending on what you mean in your query, a missing close-parenthesis at the end of line 12.

Also, just for clarity's sake, you may want to rethink the over-used alias "s" you use in lines 4, 7 and 9. You could use it in one place but not all three...it's confusing.

Edited by BitBlt: n/a

0

Yes BItbit. I got already the Error.
Sorry for my late reply.

I have lacking 1 Open Parenthesis in line 12. it should be e).

for aliasis, i should use different aliasis per line that you mention.?

0

Glad to hear you found the error.

As far as the alias change, it is not actually "necessary". Your query will run fine without that change. It was just a suggestion to avoid potential confusion among the various different scopes of query and "apply".

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.