{"Entry":{"collection":"func","key":"width-bucket","name":"width_bucket","aliases":[],"metadata":{"changed_in":["8.1","8.3","9.5","14"],"changes":[{"descriptions_changed":false,"doc_overhaul":false,"from":"7.4","group_changed":null,"signatures":{"added":[],"removed":[]},"status":"added","to":"8.0"},{"descriptions_changed":false,"doc_overhaul":false,"from":"8.0","group_changed":null,"signatures":{"added":["width_bucket ( op numeric, b1 numeric, b2 numeric, count int ) → int"],"removed":["width_bucket ( op numeric, b1 numeric, b2 numeric, count integer ) → integer"]},"status":"changed","to":"8.1"},{"descriptions_changed":true,"doc_overhaul":false,"from":"8.1","group_changed":null,"signatures":{"added":[],"removed":[]},"status":"changed","to":"8.2"},{"descriptions_changed":false,"doc_overhaul":false,"from":"8.2","group_changed":null,"signatures":{"added":["width_bucket ( op dp, b1 dp, b2 dp, count int ) → int"],"removed":[]},"status":"changed","to":"8.3"},{"descriptions_changed":true,"doc_overhaul":false,"from":"9.4","group_changed":null,"signatures":{"added":["width_bucket ( operand dp, b1 dp, b2 dp, count int ) → int","width_bucket ( operand numeric, b1 numeric, b2 numeric, count int ) → int","width_bucket ( operand anyelement, thresholds anyarray ) → int"],"removed":["width_bucket ( op numeric, b1 numeric, b2 numeric, count int ) → int","width_bucket ( op dp, b1 dp, b2 dp, count int ) → int"]},"status":"changed","to":"9.5"},{"descriptions_changed":false,"doc_overhaul":true,"from":"12","group_changed":null,"signatures":{"added":[],"removed":[]},"status":"changed","to":"13"},{"descriptions_changed":false,"doc_overhaul":false,"from":"13","group_changed":null,"signatures":{"added":["width_bucket ( operand anycompatible, thresholds anycompatiblearray ) → integer"],"removed":["width_bucket ( operand anyelement, thresholds anyarray ) → integer"]},"status":"changed","to":"14"}],"content_hash":"f932072ffa9498e581cb821eb6d581d2573bb7a04b4103776b673c007280b531","first_version":"8.0","group":"math","group_label":"Mathematical Functions And Operators","groups":["math"],"imported_at":"2026-09-27T17:57:28.299714+08:00","last_version":"20","name":"width_bucket","name_key":"width_bucket","position":2055,"present_in":["8.0","8.1","8.2","8.3","8.4","9.0","9.1","9.2","9.3","9.4","9.5","9.6","10","11","12","13","14","15","16","17","18","19","20"],"signature":"width_bucket ( operand numeric, low numeric, high numeric, count integer ) → integer","signature_count":3,"slug":"width-bucket","source_rev":"b7bd9cda","summary":"Returns the number of the bucket in which operand falls in a histogram having count equal-width buckets spanning the range low to high.","summary_zh":""}},"Definition":{"Collection":"func","Key":"width-bucket","SourceDatabase":"center","Version":"18","SourceTable":"func","SourceKey":"width-bucket","SourceRevision":"b7bd9cda","Facts":{"description":"Returns the number of the bucket in which operand falls in a histogram having count equal-width buckets spanning the range low to high. The buckets have inclusive lower bounds and exclusive upper bounds. Returns 0 for an input less than low, or count+1 for an input greater than or equal to high. If low \u003e high, the behavior is mirror-reversed, with bucket 1 now being the one just below low, and the inclusive bounds now being on the upper side.","description_html":"Returns the number of the bucket in which \u003cem class=\"parameter\"\u003e\u003ccode\u003eoperand\u003c/code\u003e\u003c/em\u003e falls in a histogram having \u003cem class=\"parameter\"\u003e\u003ccode\u003ecount\u003c/code\u003e\u003c/em\u003e equal-width buckets spanning the range \u003cem class=\"parameter\"\u003e\u003ccode\u003elow\u003c/code\u003e\u003c/em\u003e to \u003cem class=\"parameter\"\u003e\u003ccode\u003ehigh\u003c/code\u003e\u003c/em\u003e. The buckets have inclusive lower bounds and exclusive upper bounds. Returns \u003ccode class=\"literal\"\u003e0\u003c/code\u003e for an input less than \u003cem class=\"parameter\"\u003e\u003ccode\u003elow\u003c/code\u003e\u003c/em\u003e, or \u003ccode class=\"literal\"\u003e\u003cem class=\"parameter\"\u003e\u003ccode\u003ecount\u003c/code\u003e\u003c/em\u003e+1\u003c/code\u003e for an input greater than or equal to \u003cem class=\"parameter\"\u003e\u003ccode\u003ehigh\u003c/code\u003e\u003c/em\u003e. If \u003cem class=\"parameter\"\u003e\u003ccode\u003elow\u003c/code\u003e\u003c/em\u003e \u0026gt; \u003cem class=\"parameter\"\u003e\u003ccode\u003ehigh\u003c/code\u003e\u003c/em\u003e, the behavior is mirror-reversed, with bucket \u003ccode class=\"literal\"\u003e1\u003c/code\u003e now being the one just below \u003cem class=\"parameter\"\u003e\u003ccode\u003elow\u003c/code\u003e\u003c/em\u003e, and the inclusive bounds now being on the upper side.","description_zh":"","description_zh_html":"","doc":{"anchor":"FUNCTIONS-MATH-FUNC-TABLE","file":"functions-math.html","slug":"18"},"group":"math","group_label":"Mathematical Functions And Operators","lang":"en","layout":"table-new","pages":["functions-math.html"],"prose_only":false,"signatures":[{"description":"Returns the number of the bucket in which operand falls in a histogram having count equal-width buckets spanning the range low to high. The buckets have inclusive lower bounds and exclusive upper bounds. Returns 0 for an input less than low, or count+1 for an input greater than or equal to high. If low \u003e high, the behavior is mirror-reversed, with bucket 1 now being the one just below low, and the inclusive bounds now being on the upper side.","description_html":"Returns the number of the bucket in which \u003cem class=\"parameter\"\u003e\u003ccode\u003eoperand\u003c/code\u003e\u003c/em\u003e falls in a histogram having \u003cem class=\"parameter\"\u003e\u003ccode\u003ecount\u003c/code\u003e\u003c/em\u003e equal-width buckets spanning the range \u003cem class=\"parameter\"\u003e\u003ccode\u003elow\u003c/code\u003e\u003c/em\u003e to \u003cem class=\"parameter\"\u003e\u003ccode\u003ehigh\u003c/code\u003e\u003c/em\u003e. The buckets have inclusive lower bounds and exclusive upper bounds. Returns \u003ccode class=\"literal\"\u003e0\u003c/code\u003e for an input less than \u003cem class=\"parameter\"\u003e\u003ccode\u003elow\u003c/code\u003e\u003c/em\u003e, or \u003ccode class=\"literal\"\u003e\u003cem class=\"parameter\"\u003e\u003ccode\u003ecount\u003c/code\u003e\u003c/em\u003e+1\u003c/code\u003e for an input greater than or equal to \u003cem class=\"parameter\"\u003e\u003ccode\u003ehigh\u003c/code\u003e\u003c/em\u003e. If \u003cem class=\"parameter\"\u003e\u003ccode\u003elow\u003c/code\u003e\u003c/em\u003e \u0026gt; \u003cem class=\"parameter\"\u003e\u003ccode\u003ehigh\u003c/code\u003e\u003c/em\u003e, the behavior is mirror-reversed, with bucket \u003ccode class=\"literal\"\u003e1\u003c/code\u003e now being the one just below \u003cem class=\"parameter\"\u003e\u003ccode\u003elow\u003c/code\u003e\u003c/em\u003e, and the inclusive bounds now being on the upper side.","description_zh":"","description_zh_html":"","examples":[{"expr":"width_bucket(5.35, 0.024, 10.06, 5)","result":"3"},{"expr":"width_bucket(9, 10, 0, 10)","result":"2"}],"html":"\u003ccode class=\"function\"\u003ewidth_bucket\u003c/code\u003e ( \u003cem class=\"parameter\"\u003e\u003ccode\u003eoperand\u003c/code\u003e\u003c/em\u003e \u003ccode class=\"type\"\u003enumeric\u003c/code\u003e, \u003cem class=\"parameter\"\u003e\u003ccode\u003elow\u003c/code\u003e\u003c/em\u003e \u003ccode class=\"type\"\u003enumeric\u003c/code\u003e, \u003cem class=\"parameter\"\u003e\u003ccode\u003ehigh\u003c/code\u003e\u003c/em\u003e \u003ccode class=\"type\"\u003enumeric\u003c/code\u003e, \u003cem class=\"parameter\"\u003e\u003ccode\u003ecount\u003c/code\u003e\u003c/em\u003e \u003ccode class=\"type\"\u003einteger\u003c/code\u003e ) → \u003ccode class=\"returnvalue\"\u003einteger\u003c/code\u003e","returns":"integer","text":"width_bucket ( operand numeric, low numeric, high numeric, count integer ) → integer","zh_from":""},{"description":"Returns the number of the bucket in which operand falls in a histogram having count equal-width buckets spanning the range low to high. The buckets have inclusive lower bounds and exclusive upper bounds. Returns 0 for an input less than low, or count+1 for an input greater than or equal to high. If low \u003e high, the behavior is mirror-reversed, with bucket 1 now being the one just below low, and the inclusive bounds now being on the upper side.","description_html":"Returns the number of the bucket in which \u003cem class=\"parameter\"\u003e\u003ccode\u003eoperand\u003c/code\u003e\u003c/em\u003e falls in a histogram having \u003cem class=\"parameter\"\u003e\u003ccode\u003ecount\u003c/code\u003e\u003c/em\u003e equal-width buckets spanning the range \u003cem class=\"parameter\"\u003e\u003ccode\u003elow\u003c/code\u003e\u003c/em\u003e to \u003cem class=\"parameter\"\u003e\u003ccode\u003ehigh\u003c/code\u003e\u003c/em\u003e. The buckets have inclusive lower bounds and exclusive upper bounds. Returns \u003ccode class=\"literal\"\u003e0\u003c/code\u003e for an input less than \u003cem class=\"parameter\"\u003e\u003ccode\u003elow\u003c/code\u003e\u003c/em\u003e, or \u003ccode class=\"literal\"\u003e\u003cem class=\"parameter\"\u003e\u003ccode\u003ecount\u003c/code\u003e\u003c/em\u003e+1\u003c/code\u003e for an input greater than or equal to \u003cem class=\"parameter\"\u003e\u003ccode\u003ehigh\u003c/code\u003e\u003c/em\u003e. If \u003cem class=\"parameter\"\u003e\u003ccode\u003elow\u003c/code\u003e\u003c/em\u003e \u0026gt; \u003cem class=\"parameter\"\u003e\u003ccode\u003ehigh\u003c/code\u003e\u003c/em\u003e, the behavior is mirror-reversed, with bucket \u003ccode class=\"literal\"\u003e1\u003c/code\u003e now being the one just below \u003cem class=\"parameter\"\u003e\u003ccode\u003elow\u003c/code\u003e\u003c/em\u003e, and the inclusive bounds now being on the upper side.","description_zh":"","description_zh_html":"","examples":[{"expr":"width_bucket(5.35, 0.024, 10.06, 5)","result":"3"},{"expr":"width_bucket(9, 10, 0, 10)","result":"2"}],"html":"\u003ccode class=\"function\"\u003ewidth_bucket\u003c/code\u003e ( \u003cem class=\"parameter\"\u003e\u003ccode\u003eoperand\u003c/code\u003e\u003c/em\u003e \u003ccode class=\"type\"\u003edouble precision\u003c/code\u003e, \u003cem class=\"parameter\"\u003e\u003ccode\u003elow\u003c/code\u003e\u003c/em\u003e \u003ccode class=\"type\"\u003edouble precision\u003c/code\u003e, \u003cem class=\"parameter\"\u003e\u003ccode\u003ehigh\u003c/code\u003e\u003c/em\u003e \u003ccode class=\"type\"\u003edouble precision\u003c/code\u003e, \u003cem class=\"parameter\"\u003e\u003ccode\u003ecount\u003c/code\u003e\u003c/em\u003e \u003ccode class=\"type\"\u003einteger\u003c/code\u003e ) → \u003ccode class=\"returnvalue\"\u003einteger\u003c/code\u003e","returns":"integer","text":"width_bucket ( operand double precision, low double precision, high double precision, count integer ) → integer","zh_from":""},{"description":"Returns the number of the bucket in which operand falls given an array listing the inclusive lower bounds of the buckets. Returns 0 for an input less than the first lower bound. operand and the array elements can be of any type having standard comparison operators. The thresholds array must be sorted, smallest first, or unexpected results will be obtained.","description_html":"Returns the number of the bucket in which \u003cem class=\"parameter\"\u003e\u003ccode\u003eoperand\u003c/code\u003e\u003c/em\u003e falls given an array listing the inclusive lower bounds of the buckets. Returns \u003ccode class=\"literal\"\u003e0\u003c/code\u003e for an input less than the first lower bound. \u003cem class=\"parameter\"\u003e\u003ccode\u003eoperand\u003c/code\u003e\u003c/em\u003e and the array elements can be of any type having standard comparison operators. The \u003cem class=\"parameter\"\u003e\u003ccode\u003ethresholds\u003c/code\u003e\u003c/em\u003e array \u003cspan class=\"emphasis\"\u003e\u003cem\u003emust be sorted\u003c/em\u003e\u003c/span\u003e, smallest first, or unexpected results will be obtained.","description_zh":"","description_zh_html":"","examples":[{"expr":"width_bucket(now(), array['yesterday', 'today', 'tomorrow']::timestamptz[])","result":"2"}],"html":"\u003ccode class=\"function\"\u003ewidth_bucket\u003c/code\u003e ( \u003cem class=\"parameter\"\u003e\u003ccode\u003eoperand\u003c/code\u003e\u003c/em\u003e \u003ccode class=\"type\"\u003eanycompatible\u003c/code\u003e, \u003cem class=\"parameter\"\u003e\u003ccode\u003ethresholds\u003c/code\u003e\u003c/em\u003e \u003ccode class=\"type\"\u003eanycompatiblearray\u003c/code\u003e ) → \u003ccode class=\"returnvalue\"\u003einteger\u003c/code\u003e","returns":"integer","text":"width_bucket ( operand anycompatible, thresholds anycompatiblearray ) → integer","zh_from":""}],"zh_from":""},"ManualEvidence":{"doc":{"anchor":"FUNCTIONS-MATH-FUNC-TABLE","file":"functions-math.html","slug":"18"}},"MeasuredEvidence":{}},"Text":{"Collection":"func","Key":"width-bucket","SourceDatabase":"pgweb","Version":"18","Locale":"zh-Hans","Title":"width_bucket","Summary":"返回直方图中包含 operand 的桶编号。该直方图把 low 到 high 的范围划分为 count 个等宽桶。各桶包含下边界、不包含上边界。对于小于 low 的输入，返回 0；对于大于等于 high 的输入，返回 count+1。如果 low \u003e high，行为会镜像反转，此时桶 1 表示刚好位于 low 下方的那个桶，并且包含边界的一侧改为上边界。","BodyHTML":"返回直方图中包含 \u003cem\u003e\u003ccode\u003eoperand\u003c/code\u003e\u003c/em\u003e 的桶编号。该直方图把 \u003cem\u003e\u003ccode\u003elow\u003c/code\u003e\u003c/em\u003e 到 \u003cem\u003e\u003ccode\u003ehigh\u003c/code\u003e\u003c/em\u003e 的范围划分为 \u003cem\u003e\u003ccode\u003ecount\u003c/code\u003e\u003c/em\u003e 个等宽桶。各桶包含下边界、不包含上边界。对于小于 \u003cem\u003e\u003ccode\u003elow\u003c/code\u003e\u003c/em\u003e 的输入，返回 \u003ccode\u003e0\u003c/code\u003e；对于大于等于 \u003cem\u003e\u003ccode\u003ehigh\u003c/code\u003e\u003c/em\u003e 的输入，返回 \u003ccode\u003e\u003cem\u003e\u003ccode\u003ecount\u003c/code\u003e\u003c/em\u003e+1\u003c/code\u003e。如果 \u003cem\u003e\u003ccode\u003elow\u003c/code\u003e\u003c/em\u003e \u0026gt; \u003cem\u003e\u003ccode\u003ehigh\u003c/code\u003e\u003c/em\u003e，行为会镜像反转，此时桶 \u003ccode\u003e1\u003c/code\u003e 表示刚好位于 \u003cem\u003e\u003ccode\u003elow\u003c/code\u003e\u003c/em\u003e 下方的那个桶，并且包含边界的一侧改为上边界。\u003cpre\u003ewidth_bucket ( operand numeric, low numeric, high numeric, count integer ) → integer\u003c/pre\u003e返回直方图中包含 \u003cem\u003e\u003ccode\u003eoperand\u003c/code\u003e\u003c/em\u003e 的桶编号。该直方图把 \u003cem\u003e\u003ccode\u003elow\u003c/code\u003e\u003c/em\u003e 到 \u003cem\u003e\u003ccode\u003ehigh\u003c/code\u003e\u003c/em\u003e 的范围划分为 \u003cem\u003e\u003ccode\u003ecount\u003c/code\u003e\u003c/em\u003e 个等宽桶。各桶包含下边界、不包含上边界。对于小于 \u003cem\u003e\u003ccode\u003elow\u003c/code\u003e\u003c/em\u003e 的输入，返回 \u003ccode\u003e0\u003c/code\u003e；对于大于等于 \u003cem\u003e\u003ccode\u003ehigh\u003c/code\u003e\u003c/em\u003e 的输入，返回 \u003ccode\u003e\u003cem\u003e\u003ccode\u003ecount\u003c/code\u003e\u003c/em\u003e+1\u003c/code\u003e。如果 \u003cem\u003e\u003ccode\u003elow\u003c/code\u003e\u003c/em\u003e \u0026gt; \u003cem\u003e\u003ccode\u003ehigh\u003c/code\u003e\u003c/em\u003e，行为会镜像反转，此时桶 \u003ccode\u003e1\u003c/code\u003e 表示刚好位于 \u003cem\u003e\u003ccode\u003elow\u003c/code\u003e\u003c/em\u003e 下方的那个桶，并且包含边界的一侧改为上边界。\u003cpre\u003ewidth_bucket ( operand double precision, low double precision, high double precision, count integer ) → integer\u003c/pre\u003e返回直方图中包含 \u003cem\u003e\u003ccode\u003eoperand\u003c/code\u003e\u003c/em\u003e 的桶编号。该直方图把 \u003cem\u003e\u003ccode\u003elow\u003c/code\u003e\u003c/em\u003e 到 \u003cem\u003e\u003ccode\u003ehigh\u003c/code\u003e\u003c/em\u003e 的范围划分为 \u003cem\u003e\u003ccode\u003ecount\u003c/code\u003e\u003c/em\u003e 个等宽桶。各桶包含下边界、不包含上边界。对于小于 \u003cem\u003e\u003ccode\u003elow\u003c/code\u003e\u003c/em\u003e 的输入，返回 \u003ccode\u003e0\u003c/code\u003e；对于大于等于 \u003cem\u003e\u003ccode\u003ehigh\u003c/code\u003e\u003c/em\u003e 的输入，返回 \u003ccode\u003e\u003cem\u003e\u003ccode\u003ecount\u003c/code\u003e\u003c/em\u003e+1\u003c/code\u003e。如果 \u003cem\u003e\u003ccode\u003elow\u003c/code\u003e\u003c/em\u003e \u0026gt; \u003cem\u003e\u003ccode\u003ehigh\u003c/code\u003e\u003c/em\u003e，行为会镜像反转，此时桶 \u003ccode\u003e1\u003c/code\u003e 表示刚好位于 \u003cem\u003e\u003ccode\u003elow\u003c/code\u003e\u003c/em\u003e 下方的那个桶，并且包含边界的一侧改为上边界。\u003cpre\u003ewidth_bucket ( operand anycompatible, thresholds anycompatiblearray ) → integer\u003c/pre\u003e给定一个列出各桶包含性下边界的数组，返回 \u003cem\u003e\u003ccode\u003eoperand\u003c/code\u003e\u003c/em\u003e 所落入的桶编号。对于小于第一个下界的输入，返回 \u003ccode\u003e0\u003c/code\u003e。\u003cem\u003e\u003ccode\u003eoperand\u003c/code\u003e\u003c/em\u003e 和数组元素可以是任何具有标准比较操作符的类型。\u003cem\u003e\u003ccode\u003ethresholds\u003c/code\u003e\u003c/em\u003e 数组\u003cspan\u003e\u003cem\u003e必须有序\u003c/em\u003e\u003c/span\u003e，且最小值在前，否则会得到意外结果。","SourceRevision":"ca936764","ContentHash":"38a80dcafaab4ac6350a77c8991a190be9c3791a15578c100baf2e33d2ccf388","Payload":{"description_zh":"返回直方图中包含 operand 的桶编号。该直方图把 low 到 high 的范围划分为 count 个等宽桶。各桶包含下边界、不包含上边界。对于小于 low 的输入，返回 0；对于大于等于 high 的输入，返回 count+1。如果 low \u003e high，行为会镜像反转，此时桶 1 表示刚好位于 low 下方的那个桶，并且包含边界的一侧改为上边界。","description_zh_html":"返回直方图中包含 \u003cem class=\"parameter\"\u003e\u003ccode\u003eoperand\u003c/code\u003e\u003c/em\u003e 的桶编号。该直方图把 \u003cem class=\"parameter\"\u003e\u003ccode\u003elow\u003c/code\u003e\u003c/em\u003e 到 \u003cem class=\"parameter\"\u003e\u003ccode\u003ehigh\u003c/code\u003e\u003c/em\u003e 的范围划分为 \u003cem class=\"parameter\"\u003e\u003ccode\u003ecount\u003c/code\u003e\u003c/em\u003e 个等宽桶。各桶包含下边界、不包含上边界。对于小于 \u003cem class=\"parameter\"\u003e\u003ccode\u003elow\u003c/code\u003e\u003c/em\u003e 的输入，返回 \u003ccode class=\"literal\"\u003e0\u003c/code\u003e；对于大于等于 \u003cem class=\"parameter\"\u003e\u003ccode\u003ehigh\u003c/code\u003e\u003c/em\u003e 的输入，返回 \u003ccode class=\"literal\"\u003e\u003cem class=\"parameter\"\u003e\u003ccode\u003ecount\u003c/code\u003e\u003c/em\u003e+1\u003c/code\u003e。如果 \u003cem class=\"parameter\"\u003e\u003ccode\u003elow\u003c/code\u003e\u003c/em\u003e \u0026gt; \u003cem class=\"parameter\"\u003e\u003ccode\u003ehigh\u003c/code\u003e\u003c/em\u003e，行为会镜像反转，此时桶 \u003ccode class=\"literal\"\u003e1\u003c/code\u003e 表示刚好位于 \u003cem class=\"parameter\"\u003e\u003ccode\u003elow\u003c/code\u003e\u003c/em\u003e 下方的那个桶，并且包含边界的一侧改为上边界。","signatures":[{"description_zh":"返回直方图中包含 operand 的桶编号。该直方图把 low 到 high 的范围划分为 count 个等宽桶。各桶包含下边界、不包含上边界。对于小于 low 的输入，返回 0；对于大于等于 high 的输入，返回 count+1。如果 low \u003e high，行为会镜像反转，此时桶 1 表示刚好位于 low 下方的那个桶，并且包含边界的一侧改为上边界。","description_zh_html":"返回直方图中包含 \u003cem class=\"parameter\"\u003e\u003ccode\u003eoperand\u003c/code\u003e\u003c/em\u003e 的桶编号。该直方图把 \u003cem class=\"parameter\"\u003e\u003ccode\u003elow\u003c/code\u003e\u003c/em\u003e 到 \u003cem class=\"parameter\"\u003e\u003ccode\u003ehigh\u003c/code\u003e\u003c/em\u003e 的范围划分为 \u003cem class=\"parameter\"\u003e\u003ccode\u003ecount\u003c/code\u003e\u003c/em\u003e 个等宽桶。各桶包含下边界、不包含上边界。对于小于 \u003cem class=\"parameter\"\u003e\u003ccode\u003elow\u003c/code\u003e\u003c/em\u003e 的输入，返回 \u003ccode class=\"literal\"\u003e0\u003c/code\u003e；对于大于等于 \u003cem class=\"parameter\"\u003e\u003ccode\u003ehigh\u003c/code\u003e\u003c/em\u003e 的输入，返回 \u003ccode class=\"literal\"\u003e\u003cem class=\"parameter\"\u003e\u003ccode\u003ecount\u003c/code\u003e\u003c/em\u003e+1\u003c/code\u003e。如果 \u003cem class=\"parameter\"\u003e\u003ccode\u003elow\u003c/code\u003e\u003c/em\u003e \u0026gt; \u003cem class=\"parameter\"\u003e\u003ccode\u003ehigh\u003c/code\u003e\u003c/em\u003e，行为会镜像反转，此时桶 \u003ccode class=\"literal\"\u003e1\u003c/code\u003e 表示刚好位于 \u003cem class=\"parameter\"\u003e\u003ccode\u003elow\u003c/code\u003e\u003c/em\u003e 下方的那个桶，并且包含边界的一侧改为上边界。","returns":"integer","text":"width_bucket ( operand numeric, low numeric, high numeric, count integer ) → integer","zh_from":"doc"},{"description_zh":"返回直方图中包含 operand 的桶编号。该直方图把 low 到 high 的范围划分为 count 个等宽桶。各桶包含下边界、不包含上边界。对于小于 low 的输入，返回 0；对于大于等于 high 的输入，返回 count+1。如果 low \u003e high，行为会镜像反转，此时桶 1 表示刚好位于 low 下方的那个桶，并且包含边界的一侧改为上边界。","description_zh_html":"返回直方图中包含 \u003cem class=\"parameter\"\u003e\u003ccode\u003eoperand\u003c/code\u003e\u003c/em\u003e 的桶编号。该直方图把 \u003cem class=\"parameter\"\u003e\u003ccode\u003elow\u003c/code\u003e\u003c/em\u003e 到 \u003cem class=\"parameter\"\u003e\u003ccode\u003ehigh\u003c/code\u003e\u003c/em\u003e 的范围划分为 \u003cem class=\"parameter\"\u003e\u003ccode\u003ecount\u003c/code\u003e\u003c/em\u003e 个等宽桶。各桶包含下边界、不包含上边界。对于小于 \u003cem class=\"parameter\"\u003e\u003ccode\u003elow\u003c/code\u003e\u003c/em\u003e 的输入，返回 \u003ccode class=\"literal\"\u003e0\u003c/code\u003e；对于大于等于 \u003cem class=\"parameter\"\u003e\u003ccode\u003ehigh\u003c/code\u003e\u003c/em\u003e 的输入，返回 \u003ccode class=\"literal\"\u003e\u003cem class=\"parameter\"\u003e\u003ccode\u003ecount\u003c/code\u003e\u003c/em\u003e+1\u003c/code\u003e。如果 \u003cem class=\"parameter\"\u003e\u003ccode\u003elow\u003c/code\u003e\u003c/em\u003e \u0026gt; \u003cem class=\"parameter\"\u003e\u003ccode\u003ehigh\u003c/code\u003e\u003c/em\u003e，行为会镜像反转，此时桶 \u003ccode class=\"literal\"\u003e1\u003c/code\u003e 表示刚好位于 \u003cem class=\"parameter\"\u003e\u003ccode\u003elow\u003c/code\u003e\u003c/em\u003e 下方的那个桶，并且包含边界的一侧改为上边界。","returns":"integer","text":"width_bucket ( operand double precision, low double precision, high double precision, count integer ) → integer","zh_from":"doc"},{"description_zh":"给定一个列出各桶包含性下边界的数组，返回 operand 所落入的桶编号。对于小于第一个下界的输入，返回 0。operand 和数组元素可以是任何具有标准比较操作符的类型。thresholds 数组必须有序，且最小值在前，否则会得到意外结果。","description_zh_html":"给定一个列出各桶包含性下边界的数组，返回 \u003cem class=\"parameter\"\u003e\u003ccode\u003eoperand\u003c/code\u003e\u003c/em\u003e 所落入的桶编号。对于小于第一个下界的输入，返回 \u003ccode class=\"literal\"\u003e0\u003c/code\u003e。\u003cem class=\"parameter\"\u003e\u003ccode\u003eoperand\u003c/code\u003e\u003c/em\u003e 和数组元素可以是任何具有标准比较操作符的类型。\u003cem class=\"parameter\"\u003e\u003ccode\u003ethresholds\u003c/code\u003e\u003c/em\u003e 数组\u003cspan class=\"emphasis\"\u003e\u003cem\u003e必须有序\u003c/em\u003e\u003c/span\u003e，且最小值在前，否则会得到意外结果。","returns":"integer","text":"width_bucket ( operand anycompatible, thresholds anycompatiblearray ) → integer","zh_from":"doc"}],"zh_from":"doc"}},"RequestedLocale":"zh-Hans","Fallback":false,"Versions":["10","11","12","13","14","15","16","17","18","19","20","8.0","8.1","8.2","8.3","8.4","9.0","9.1","9.2","9.3","9.4","9.5","9.6"],"Locales":["en","zh-Hans"],"Signatures":[{"Version":"18","Ordinal":0,"Hash":"4b2eeb72d11b6f5ca7da79dd259f79419723405be87f24215c72a48709386058","Text":"width_bucket ( operand numeric, low numeric, high numeric, count integer ) → integer","Returns":"integer","Payload":{"description":"Returns the number of the bucket in which operand falls in a histogram having count equal-width buckets spanning the range low to high. The buckets have inclusive lower bounds and exclusive upper bounds. Returns 0 for an input less than low, or count+1 for an input greater than or equal to high. If low \u003e high, the behavior is mirror-reversed, with bucket 1 now being the one just below low, and the inclusive bounds now being on the upper side.","description_html":"Returns the number of the bucket in which \u003cem class=\"parameter\"\u003e\u003ccode\u003eoperand\u003c/code\u003e\u003c/em\u003e falls in a histogram having \u003cem class=\"parameter\"\u003e\u003ccode\u003ecount\u003c/code\u003e\u003c/em\u003e equal-width buckets spanning the range \u003cem class=\"parameter\"\u003e\u003ccode\u003elow\u003c/code\u003e\u003c/em\u003e to \u003cem class=\"parameter\"\u003e\u003ccode\u003ehigh\u003c/code\u003e\u003c/em\u003e. The buckets have inclusive lower bounds and exclusive upper bounds. Returns \u003ccode class=\"literal\"\u003e0\u003c/code\u003e for an input less than \u003cem class=\"parameter\"\u003e\u003ccode\u003elow\u003c/code\u003e\u003c/em\u003e, or \u003ccode class=\"literal\"\u003e\u003cem class=\"parameter\"\u003e\u003ccode\u003ecount\u003c/code\u003e\u003c/em\u003e+1\u003c/code\u003e for an input greater than or equal to \u003cem class=\"parameter\"\u003e\u003ccode\u003ehigh\u003c/code\u003e\u003c/em\u003e. If \u003cem class=\"parameter\"\u003e\u003ccode\u003elow\u003c/code\u003e\u003c/em\u003e \u0026gt; \u003cem class=\"parameter\"\u003e\u003ccode\u003ehigh\u003c/code\u003e\u003c/em\u003e, the behavior is mirror-reversed, with bucket \u003ccode class=\"literal\"\u003e1\u003c/code\u003e now being the one just below \u003cem class=\"parameter\"\u003e\u003ccode\u003elow\u003c/code\u003e\u003c/em\u003e, and the inclusive bounds now being on the upper side.","description_zh":"","description_zh_html":"","examples":[{"expr":"width_bucket(5.35, 0.024, 10.06, 5)","result":"3"},{"expr":"width_bucket(9, 10, 0, 10)","result":"2"}],"html":"\u003ccode class=\"function\"\u003ewidth_bucket\u003c/code\u003e ( \u003cem class=\"parameter\"\u003e\u003ccode\u003eoperand\u003c/code\u003e\u003c/em\u003e \u003ccode class=\"type\"\u003enumeric\u003c/code\u003e, \u003cem class=\"parameter\"\u003e\u003ccode\u003elow\u003c/code\u003e\u003c/em\u003e \u003ccode class=\"type\"\u003enumeric\u003c/code\u003e, \u003cem class=\"parameter\"\u003e\u003ccode\u003ehigh\u003c/code\u003e\u003c/em\u003e \u003ccode class=\"type\"\u003enumeric\u003c/code\u003e, \u003cem class=\"parameter\"\u003e\u003ccode\u003ecount\u003c/code\u003e\u003c/em\u003e \u003ccode class=\"type\"\u003einteger\u003c/code\u003e ) → \u003ccode class=\"returnvalue\"\u003einteger\u003c/code\u003e","returns":"integer","text":"width_bucket ( operand numeric, low numeric, high numeric, count integer ) → integer","zh_from":""}},{"Version":"18","Ordinal":1,"Hash":"a105aff443e4911e4d9e01ac7b1454459643d65a1b7e728d98a6e25cdf1982ee","Text":"width_bucket ( operand double precision, low double precision, high double precision, count integer ) → integer","Returns":"integer","Payload":{"description":"Returns the number of the bucket in which operand falls in a histogram having count equal-width buckets spanning the range low to high. The buckets have inclusive lower bounds and exclusive upper bounds. Returns 0 for an input less than low, or count+1 for an input greater than or equal to high. If low \u003e high, the behavior is mirror-reversed, with bucket 1 now being the one just below low, and the inclusive bounds now being on the upper side.","description_html":"Returns the number of the bucket in which \u003cem class=\"parameter\"\u003e\u003ccode\u003eoperand\u003c/code\u003e\u003c/em\u003e falls in a histogram having \u003cem class=\"parameter\"\u003e\u003ccode\u003ecount\u003c/code\u003e\u003c/em\u003e equal-width buckets spanning the range \u003cem class=\"parameter\"\u003e\u003ccode\u003elow\u003c/code\u003e\u003c/em\u003e to \u003cem class=\"parameter\"\u003e\u003ccode\u003ehigh\u003c/code\u003e\u003c/em\u003e. The buckets have inclusive lower bounds and exclusive upper bounds. Returns \u003ccode class=\"literal\"\u003e0\u003c/code\u003e for an input less than \u003cem class=\"parameter\"\u003e\u003ccode\u003elow\u003c/code\u003e\u003c/em\u003e, or \u003ccode class=\"literal\"\u003e\u003cem class=\"parameter\"\u003e\u003ccode\u003ecount\u003c/code\u003e\u003c/em\u003e+1\u003c/code\u003e for an input greater than or equal to \u003cem class=\"parameter\"\u003e\u003ccode\u003ehigh\u003c/code\u003e\u003c/em\u003e. If \u003cem class=\"parameter\"\u003e\u003ccode\u003elow\u003c/code\u003e\u003c/em\u003e \u0026gt; \u003cem class=\"parameter\"\u003e\u003ccode\u003ehigh\u003c/code\u003e\u003c/em\u003e, the behavior is mirror-reversed, with bucket \u003ccode class=\"literal\"\u003e1\u003c/code\u003e now being the one just below \u003cem class=\"parameter\"\u003e\u003ccode\u003elow\u003c/code\u003e\u003c/em\u003e, and the inclusive bounds now being on the upper side.","description_zh":"","description_zh_html":"","examples":[{"expr":"width_bucket(5.35, 0.024, 10.06, 5)","result":"3"},{"expr":"width_bucket(9, 10, 0, 10)","result":"2"}],"html":"\u003ccode class=\"function\"\u003ewidth_bucket\u003c/code\u003e ( \u003cem class=\"parameter\"\u003e\u003ccode\u003eoperand\u003c/code\u003e\u003c/em\u003e \u003ccode class=\"type\"\u003edouble precision\u003c/code\u003e, \u003cem class=\"parameter\"\u003e\u003ccode\u003elow\u003c/code\u003e\u003c/em\u003e \u003ccode class=\"type\"\u003edouble precision\u003c/code\u003e, \u003cem class=\"parameter\"\u003e\u003ccode\u003ehigh\u003c/code\u003e\u003c/em\u003e \u003ccode class=\"type\"\u003edouble precision\u003c/code\u003e, \u003cem class=\"parameter\"\u003e\u003ccode\u003ecount\u003c/code\u003e\u003c/em\u003e \u003ccode class=\"type\"\u003einteger\u003c/code\u003e ) → \u003ccode class=\"returnvalue\"\u003einteger\u003c/code\u003e","returns":"integer","text":"width_bucket ( operand double precision, low double precision, high double precision, count integer ) → integer","zh_from":""}},{"Version":"18","Ordinal":2,"Hash":"5886a2e14983c376db0be985ce4b4d83aecdd2c4edeb12dd2ad2418f155c430f","Text":"width_bucket ( operand anycompatible, thresholds anycompatiblearray ) → integer","Returns":"integer","Payload":{"description":"Returns the number of the bucket in which operand falls given an array listing the inclusive lower bounds of the buckets. Returns 0 for an input less than the first lower bound. operand and the array elements can be of any type having standard comparison operators. The thresholds array must be sorted, smallest first, or unexpected results will be obtained.","description_html":"Returns the number of the bucket in which \u003cem class=\"parameter\"\u003e\u003ccode\u003eoperand\u003c/code\u003e\u003c/em\u003e falls given an array listing the inclusive lower bounds of the buckets. Returns \u003ccode class=\"literal\"\u003e0\u003c/code\u003e for an input less than the first lower bound. \u003cem class=\"parameter\"\u003e\u003ccode\u003eoperand\u003c/code\u003e\u003c/em\u003e and the array elements can be of any type having standard comparison operators. The \u003cem class=\"parameter\"\u003e\u003ccode\u003ethresholds\u003c/code\u003e\u003c/em\u003e array \u003cspan class=\"emphasis\"\u003e\u003cem\u003emust be sorted\u003c/em\u003e\u003c/span\u003e, smallest first, or unexpected results will be obtained.","description_zh":"","description_zh_html":"","examples":[{"expr":"width_bucket(now(), array['yesterday', 'today', 'tomorrow']::timestamptz[])","result":"2"}],"html":"\u003ccode class=\"function\"\u003ewidth_bucket\u003c/code\u003e ( \u003cem class=\"parameter\"\u003e\u003ccode\u003eoperand\u003c/code\u003e\u003c/em\u003e \u003ccode class=\"type\"\u003eanycompatible\u003c/code\u003e, \u003cem class=\"parameter\"\u003e\u003ccode\u003ethresholds\u003c/code\u003e\u003c/em\u003e \u003ccode class=\"type\"\u003eanycompatiblearray\u003c/code\u003e ) → \u003ccode class=\"returnvalue\"\u003einteger\u003c/code\u003e","returns":"integer","text":"width_bucket ( operand anycompatible, thresholds anycompatiblearray ) → integer","zh_from":""}}],"Spellings":null,"SQLState":null,"Evidence":null}
