"min ()" with two parameters

0

The person who worked before me at the company made this code:

MIN(DATEPART('weekday',[Entrega Data Real]),6)

What does this 6 mean?

Can min() have two parameters?

    
asked by anonymous 26.12.2017 / 14:04

1 answer

2

No, we can not know what it means, but by code the result should give a maximum of 6, ie if the day of the week is 7 (probably Sunday, it depends on the culture used) then it will consider 6 Saturday), but if it is any days under 7, it will consider the day of the delivery week.

A min() function must have at least two arguments since it results in a minimum value between two or more of them. If it had only one argument the result would always be itself.

Note that in this case it is not being used as aggregation but rather a simple expression, it only takes the value of a column in a row and compares it with the literal 6. This is done line by line but is not looking for the least of all the lines, as you probably are thinking. It only works to aggregate if you have any clause in query have something that groups everything. Nothing posted indicates this and even if it is used so the form of the written function would not do the aggregation correctly.

    
26.12.2017 / 14:33