When min date is 2009.01.01 , how come the result below has a 2008.12.27?
Hi @vjay.b5, here is another example to try help explain:
tab:([]date:2009.01.01+ til 31; temp: 31?50; humid:31?100)
tab
date temp humid
---------------------
2009.01.01 39 14
2009.01.02 2 32
2009.01.03 33 22
2009.01.04 6 62
2009.01.05 11 34
2009.01.06 40 29
2009.01.07 33 33
2009.01.08 1 10
2009.01.09 20 78
2009.01.10 21 42
2009.01.11 13 22
2009.01.12 32 81
2009.01.13 5 92
2009.01.14 6 78
2009.01.15 34 94
2009.01.16 49 9
2009.01.17 28 19
2009.01.18 38 75
2009.01.19 31 34
2009.01.20 18 84
2009.01.21 9 1
2009.01.22 25 97
2009.01.23 4 90
2009.01.24 36 80
2009.01.25 34 65
2009.01.26 25 8
2009.01.27 30 41
2009.01.28 4 51
2009.01.29 7 44
2009.01.30 13 58
2009.01.31 26 11
select min temp, max humid by 7 xbar date from tab
date | temp humid
----------| ----------
2008.12.27| 2 32
2009.01.03| 1 78
2009.01.10| 5 94
2009.01.17| 4 97
2009.01.24| 4 80
2009.01.31| 26 11
x xbar y returns y rounded down to the nearest multiple of x, so in order for this to work with the dates, it returns 2008.12.27 as it’s 7 days before 2009.01.03. It doesn’t mean that the table contains data for < 2009.12.27.
You can read more about xbar here: xbar | Reference | kdb+ and q documentation
Hope that helps!
Laura
