I have borrowed a query and adapted it for my own purposes, but I don't like doing this when I am not entirely sure what it is doing. SQL docs are less than descriptive on this clause. Here is what I borrowed and modified, can you tell me what it is doing basically?
(SELECT Id FROM
(
SELECT
Id
,RANK() OVER ( PARTITION BY DropStatusId ORDER BY StatusDate DESC) [Rank]
FROM
[dbo].[tblLHTrackingHistory] [TempHistory]
WHERE
[TempHistory].[DropStatusId] = [DropStatus].[Id]
) [TT1] WHERE [Rank] = 1
)
Always use "could" if you are asking for a favour. Can is generally used to comment on the capability of a person to perform a task. So, when you ask "Can you explain it to me?", you are basically asking whether the opposite person is capable of explaining something.
'Can' refers to a general truth or something that has a strong sense of possibility. 'Could' refers to something that has a weak possibility, or something that might happen, but is not necessarily a general truth.
Should a question start with "can you please" or "could you please"? If both are correct, what is the difference between them? Answer: Both are technically correct, but the "Could you" form is polite (and preferable), while the "Can you" is almost an implied command that leaves no choice to the doer.
We also use 'could' to ask permission; it is more polite or formal than 'can'. Changing the word order to "could you please" is no more or less polite - it's a matter of style. whether requests starting with "Please can/could you..." render the same degree of politeness as those that start with "Could you please...".
The OVER
clause means you're using analytics (vs say aggregates). Per the OVER documentation:
Determines the partitioning and ordering of the rowset before the associated window function is applied.
Unlike aggregates, analytics don't require a GROUP BY
to be defined.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With