供應商特定的函數 常數 常數是您可以在表示式中使用的固定值。 運算子 運算子會指定運算子兩端的值會發生什麼事。運算子與函數相似,它們都會運用資料項目並傳回結果。 日期 插入現行系統日期。 日期時間 插入現行系統日期和時間。 包含時區的時間 插入值為零的包含時區的時間。 包含時區的時間戳記 插入包含時區的時間戳記範例。 插入 False 值。 間隔時間 插入零間隔時間:000 00:00:00.000。 年間隔時間 插入零年間隔時間:0 年。 月間隔時間 插入零月間隔時間:0 月。 年到月間隔時間 插入零年到月間隔時間:0000-00 年到月。 日間隔時間 插入零日間隔時間:0 日。 小時間隔時間 插入零小時間隔時間:0 小時。 分鐘間隔時間 插入零分鐘間隔時間:0 分鐘。 秒間隔時間 插入零秒間隔時間:0 秒。 日到小時間隔時間 插入零日到小時間隔時間:0 00 日到小時。 日到分鐘間隔時間 插入零日到分鐘間隔時間:0 00:00 日到分鐘。 日到秒間隔時間 插入零日到秒間隔時間:0 00:00:00.000000000 日到秒。 小時到分鐘間隔時間 插入零小時到分鐘間隔時間:00:00 小時到分鐘。 小時到秒間隔時間 插入零小時到秒間隔時間:00:00:00.000000000 小時到秒。 分鐘到秒間隔時間 插入零分鐘到秒間隔時間:00:00:00.000000000 分鐘到秒。 如果不符合表示式條件,則會插入空值。 數字 插入數字 0,可使用新數值來取代此數字。 字串 插入以兩個單引號來表示的空字串,您可以在這兩個單引號之間輸入字串。 時間 插入現行系統時間。 插入 True 值。
識別表示式的開頭。 ( expression ) 識別表示式的結尾。 ( expression ) 將兩個數值相乘。 value1 * value2 , 區隔表示式元件。 expression ( parameter1, parameter2 ) 將兩個數值相除。 value1 / value2 連結或結合字串。 string1 || string2 將兩個數值相加。 value1 + value2 將兩個數值相減,或使數值變負。 value1 - value2 或 - value 將 "value1" 代表的值與 "value2" 相比較,然後擷取小於 "value2" 的值。 value1 < value2 將 "value1" 代表的值與 "value2" 相比較,然後擷取小於或等於 "value2" 的值。 value1 <= value2 將 "value1" 代表的值與 "value2" 相比較,然後擷取不等於 "value2" 的值。 value1 <> value2 將 "value1" 代表的值與 "value2" 相比較,然後擷取等於 "value2" 的值。 value1 = value2 將 "value1" 代表的值與 "value2" 相比較,然後擷取大於 "value2" 的值。 value1 > value2 區隔文字成員表示式中的元件。 [namespace].[dimension].[hierarchy].[level]->[L1] 將 "value1" 代表的值與 "value2" 相比較,然後擷取大於或等於 "value2" 的值。 value1 >= value2 如果表示式兩端的條件均為真,則會傳回 "true"。 argument1 and argument2 與摘要表示式一起使用,用於定義查詢中要根據分組直欄進行調整的範圍。範圍取決於環境定義。 aggregate_function ( expression AUTO ) 確定值是否落在給定的範圍中。 表示式 between value1 and value2 範例:[收入] between 200 and 300 結果:傳回收入介於 200 及 300 之間的結果數。 Revenue Between ---- ---- $332.06 false $230.55 true $107.94 false 與 when、then、else 和 end 一起使用。Case 會識別特定狀況的開始處,而該狀況已定義 when、then 和 else 動作。 case expression { when expression then expression } [ else expression ] end 判斷 "string1" 是否包含 "string2"。此語法支援兩個 meta 字元:百分比符號 (%) 代表零個、一個或多個字元,而底線符號 (_) 代表任何字元。選用的 LITERAL 關鍵字表示如何解譯 '%' 及 '_'。出現 LITERAL 關鍵字時,'%' 及 '_' 不應視為 meta 字元(請參閱範例 3 和 5)。否則,在沒有 LITERAL 關鍵字的情況下,'%' 及 '_' 的行為會如同 meta 字元(請參閱範例 1、2 和 4)。 string1 包含 [LITERAL] string2 範例 1:[PRODUCT_LINE] 包含 'door' 結果 1:戶外器材 範例 2:[PRODUCT_LINE] 包含 'Golf%' 結果 2:高爾夫球器材 範例 3:[PRODUCT_LINE] 包含文字 'Golf%' 結果 3:Golf% 範例 4:[PRODUCT_LINE] 包含'Current_Year%' 結果 4:Current Year Price、Current Year Price%、Current_Year Price%。 範例 5:[PRODUCT_LINE] 包含文字 'Current_Year%' 結果 5:Current_Year%。 可用來作為成員摘要函數的第一個引數的關鍵字。此函數出現在 GO 資料倉儲(查詢)套件中的國家/地區總收入樣本報告中。 aggregate_function ( currentMeasure within set expression ) current_date 傳回資料庫的現行日期。 current_date 與 lookup 建構一起使用。 lookup (....) in (....) default (....) 在彙總表示式中使用的關鍵字,僅包括與其他值不同的值。另請參閱 unique 函數。 distinct 資料項目 範例:count ( distinct [OrderDetailQuantity] ) 結果:1704 與 if 或 case 建構一起使用。如果 if 條件或 case 表示式不是 true,則會使用 else 表示式。此函數出現在 GO 資料倉儲(分析)套件中的 2005 年前 10 大零售商樣本報告中。 if ( condition ) then .... else ( expression ) , 或 case .... else ( expression ) end 表示 case 結束或 when 建構。 case .... end 判斷 "string1" 是否以 "string2" 結束。此語法支援兩個 meta 字元:百分比符號 (%) 代表零個、一個或多個字元,而底線符號 (_) 代表任何字元。選用的 LITERAL 關鍵字表示如何解譯 '%' 及 '_'。出現 LITERAL 關鍵字時,'%' 及 '_' 不應視為 meta 字元(請參閱範例 3 和 5)。否則,在沒有 LITERAL 關鍵字的情況下,'%' 及 '_' 的行為會如同 meta 字元(請參閱範例 1、2 和 4)。 string1 ends with [LITERAL] string2 範例 1:[PRODUCT_LINE] 以 'Equipment' 結束 結果 1:露營器材、高爾夫球器材 範例 2:[PRODUCT_LINE] 以 '%Equipment' 結束 結果 2:高爾夫球器材、露營器材 範例 3:[PRODUCT_LINE] 以文字 'Equipment%' 結束 結果 3:Equipment% 範例 4:[PRODUCT_LINE] 以 '%Price' 結束 結果 4:Product Price、Current_Year Price 範例 5:[PRODUCT_LINE] 以文字 '%Price' 結束 結果 5:%Price 判斷 "string1" 是否符合 "string2" 的型樣,而字元 "char" 是選擇性地用來使型樣字串中的字元跳出。 string1 LIKE string2 [ ESCAPE char ] 範例:[PRODUCT_LINE] like 'G%' 結果:所有以 'G' 開頭的產品線。 範例:[PRODUCT_LINE] like '%Ga%' escape 'a' 結果:所有以 'G' 結尾的產品線。 與摘要表示式一起使用,用來定義查詢中的彙總範圍。 aggregate_function ( expression for expression { , expression } ) 與摘要表示式一起使用,用來定義查詢中要根據分組直欄的子集進行調整的範圍。相當於 for 子句。 aggregate_function ( expression for ANY expression { , expression } ) 與摘要表示式一起使用,用來將範圍定義為查詢中所有指定的分組直欄。另請參閱 for 子句。 aggregate_function ( expression for ALL expression { , expression } ) 與摘要表示式一起使用,用來將範圍設定為整個查詢。另請參閱 for 子句。此函數出現在 GO 資料倉儲(分析)套件中的客戶收入和滿意度樣本報告中。 aggregate_function ( expression for report ) 與 then 和 else 建構一起使用。If 會定義條件;當 if 條件為 true 時,則會使用 then 表示式。當 if 條件不為 true 時,則會使用 else 表示式。此函數出現在 GO 資料倉儲(分析)套件中的 2005 年前 10 大零售商樣本報告中。 if ( condition ) then ( expression ) else ( expression ) 判斷 "expression1" 是否位於給定的表示式清單中。 expression1 in ( expression_list ) 判斷 "expression1" 是否位於給定的常數值或範圍清單中。 expression1 in_range { constant : constant [ , constant : constant ] } 範例:[代碼] in_range { 5 } 結果:這相當於 [代碼] = 5。 範例:[代碼] in_range { 5: } 結果:這相當於 [代碼] >= 5。 範例:[代碼] in_range { :5 } 結果:這相當於 [代碼] <= 5。 範例:[代碼] in_range { 5:10 } 結果:這相當於 ( [代碼] >= 5 and [代碼] <= 10 )。 範例:[代碼] in_range { :5,10,20: } 結果:這相當於 ( [代碼] <= 5 or [代碼] = 10 or [代碼] >= 20 )。 判斷是否未在資料中定義 "value"。 value is missing 判斷是否未在資料中定義 "value"。 value is null 判斷是否已在資料中定義 "value"。 value is not missing 判斷是否已在資料中定義 "value"。 value is not null 判斷 "string1" 是否符合 "string2" 的型樣,而字元 "char" 是選擇性地用來使型樣字串中的字元跳出。此語法支援兩個 meta 字元:百分比符號 (%) 代表零個、一個或多個字元,而底線符號 (_) 代表任何字元。 string1 LIKE string2 [ ESCAPE char ] 範例 1:[PRODUCT_LINE] like 'G%' 結果 1:以 'G' 開頭的所有產品線。 範例 2:[PRODUCT_LINE] like '%Ga%' escape 'a' 結果 2:所有以 'G' 結尾的產品線。 範例 3:[PRODUCT_LINE] like 'C_R_' 結果 3:名稱為 CARS 或 CARD 的所有產品線。 範例:lookup ( [國家]) in ( '加拿大'--> ( [標價] * 0.60), '澳大利亞'--> ( [標價] * 0.80 ) ) default ( [標價] ) 尋找資料,並使用您指定的值來取代該資料。最好使用 case 建構。 lookup ( name ) in ( value1 --> value2 ) default ( expression ) 如果 "argument" 為 false,會傳回 TRUE,如果 "argument" 為 true,則會傳回 FALSE。 NOT argument 如果 "argument1" 或 "argument2" 為 true,則會傳回 TRUE。 argument1 or argument2 執行摘要計算後再套用摘要過濾器。 summary_function ([expression] prefilter) 範例:total ( [Quantity] for report prefilter ) summaryFilter: total( [Quantity] for [ProductNo] ) > 50000 結果:套用摘要過濾器之前,總計報告中的數量。 PNo Total Total Total forPNo forRep forRep_Prefilter --------- -------- ---------- ------------------- 88 54928 298140 2215354 89 51126 298140 2215354 90 69996 298140 2215354 94 69004 298140 2215354 95 53086 298140 2215354 計算查詢輸出的列數。與 Count () 一起使用。 count ( ROWS ) 計算查詢輸出的列數。與 Count () 一起使用。 count ( ROWS  [ expression ]) 判斷 "string1" 是否是以 "string2" 開始。此語法支援兩個 meta 字元:百分比符號 (%) 代表零個、一個或多個字元,而底線符號 (_) 代表任何字元。選用的 LITERAL 關鍵字表示如何解譯 '%' 及 '_'。出現 LITERAL 關鍵字時,'%' 及 '_' 不應視為 meta 字元(請參閱範例 3 和 5)。否則,在沒有 LITERAL 關鍵字的情況下,'%' 及 '_' 的行為會如同 meta 字元(請參閱範例 1、2 和 4)。 string1 starts with [LITERAL] string2 範例 1:[PRODUCT_LINE] 以 'Golf' 開頭 結果 1:高爾夫球器材 範例 2:[PRODUCT_LINE] 以 'Outdoor%' 開頭 結果 2:戶外器材 範例 3:[PRODUCT_LINE] 以文字 'Golf%' 開頭 結果 3:Golf% 範例 4:[PRODUCT_LINE] 以 'Current_Year%' 開頭 結果 4:Current Year Price、Current Year Price%、Current_Year Price% 範例 5:[PRODUCT_LINE] 以文字 'Current_Year%' 開頭 結果 5:Current_Year% 與 if 或 case 建構一起使用。當 if 條件或 when 表示式為 true 時,會使用 then 表示式。此函數出現在 GO 資料倉儲(分析)套件中的 2005 年前 10 大零售商樣本報告中。 if ( condition ) then ...,或 case expression when expression then .... end 與 case 建構一起使用。您可以定義當 WHEN 表示式為 true 時要發生的狀況。 case [expression] when ... end
摘要 此清單包含預先定義的函數,這些函數會傳回一組相關值的單一摘要值,或針對每個實例的一組相關值傳回不同的摘要值。 根據表示式的聚集類型,傳回使用適當的聚集函數計算的值。此函數出現在 GO 資料倉儲(分析)套件中的預算與實際樣本報告中。 aggregate ( expression [ auto ] ) aggregate ( expression for [ all|any ] expression { , expression } ) aggregate ( expression for report ) 傳回選取的資料項目的平均值。Distinct 是替代表示式,它與產品早期的版本相容。 average ( [ distinct ] expression [ auto ] ) average ( [ distinct ] expression for [ all|any ] expression { , expression } ) average ( [ distinct ] expression for report ) 範例:average ( 銷售額 ) 結果:傳回所有「銷售額」值的平均值。 傳回選取的資料項目數(不包括空值)。Distinct 是替代表示式,它與產品早期的版本相容。僅在 DQM 模式中全部支援,並且它避免雙重計算維度表格的資料項目的推測。 count ( [ all | distinct ] expression [ auto ] ) count ( [ all | distinct ] expression for [ all|any ] expression { , expression } ) count ( [ all | distinct ] expression for report ) 範例:count ( 銷售額 ) 結果:傳回「銷售額」下的項目總數。 傳回選取的資料項目的最大值。Distinct 是替代表示式,它與產品早期的版本相容。 maximum ( [ distinct ] expression [ auto ] ) maximum ( [ distinct ] expression for [ all|any ] expression { , expression } ) maximum ( [ distinct ] expression for report ) 範例:maximum ( 銷售額 ) 結果:傳回所有「銷售額」值中的最大值。 傳回選取的資料項目的中位數值。 median ( expression [ auto ] ) median ( expression for [ all|any ] expression { , expression } ) median ( expression for report ) 傳回選取的資料項目的最小值。Distinct 是替代表示式,它與產品早期的版本相容。 minimum ( [ distinct ] expression [ auto ] ) minimum ( [ distinct ] expression for [ all|any ] expression { , expression } ) minimum ( [ distinct ] expression for report ) 範例:minimum ( 銷售額 ) 結果:傳回所有「銷售額」值中的最小值。 依列傳回指定的一組值在指定的列數上的移動平均值。"<for-option>" 定義函數的範圍。"at" 選項會定義彙總的層次,而且只能在關聯式資料來源的環境定義中使用。 moving-average ( numeric_expression , numeric_expression [ at expression { , expression } ] [ <for-option> ] [ prefilter ] ) moving-average (  numeric_expression , numeric_expression [ <for-option> ] [ prefilter ] ) <for-option> ::= for expression { , expression }|for report|auto 範例:moving-average ( 數量 , 3 ) 結果:對於每一列,會傳回數量及現行列與前兩列的移動平均值。 Qty Moving-Average (Qty, 3) ------ ------------------------------------ 200 200 700 450 400 433.3333 200 433.3333 200 266.6667 500 300.0000 依列傳回指定的一組值在指定的列數上的移動總計值。"<for-option>" 定義函數的範圍。"at" 選項會定義彙總的層次,而且只能在關聯式資料來源的環境定義中使用。 moving-total ( numeric_expression , numeric_expression [ at expression { , expression } ] [ <for-option> ] [ prefilter ] ) moving-total (  numeric_expression , numeric_expression [ <for-option> ] [ prefilter ] ) <for-option> ::= for expression { , expression }|for report|auto 範例:moving-total ( 數量 , 3 ) 結果:對於每一列,會傳回數量及現行列與前兩列的移動總計值。 Qty Moving-Total (Qty, 3) ------ -------------------------------- 200 200 700 900 400 1300 200 1300 200 800 500 900 傳回選取的資料項目在總值中所佔的百分比。"<for-option>" 定義函數的範圍。"at" 選項會定義彙總的層次,而且只能在關聯式資料來源的環境定義中使用。此函數出現在「百分比計算(依年份)」互動式樣本報告中。 percentage ( numeric_expression [ at expression  { , expression } ] [ <for-option> ] [ prefilter ] ) percentage (  numeric_expression [ <for-option> ] [ prefilter ] ) <for-option> ::= for expression { , expression }|for report|auto 範例:percentage ( 銷售額 98 ) 結果:傳回歸給每個銷售代表的銷售額在 1998 年的總銷售額中所佔的百分比。 Employee Sales 98 Percentage --------- --------- ------------- Gibbons 60646 7.11% Flertjan 62523 7.35% Cornel 22396 2.63% 傳回範圍在一百內的值,此值會指出等於或低於選取的資料項目的部分在總分配量中所佔的百分比。"<for-option>" 定義函數的範圍。"at" 選項會定義彙總的層次,而且只能在關聯式資料來源的環境定義中使用。 percentile ( numeric_expression [ at expression { , expression } ] [ <for-option> ] [ prefilter ] ) percentile (  numeric_expression [ <for-option> ] [ prefilter ] ) <for-option> ::= for expression { , expression }|for report|auto 範例:percentile ( 銷售額 98 ) 結果:對於每一列,傳回等於或小於該列數量值的列所佔的百分比。 Qty Percentile (Qty) ------ ----------------- 800 1 700 0.875 600 0.75 500 0.625 400 0.5 400 0.5 200 0.25 200 0.25 傳回您指定的範圍內的值的等級。它會傳回整數,代表任何範圍的等級,例如 1(最高)到 100(最低)。"<for-option>" 定義函數的範圍。"at" 選項會定義彙總的層次,而且只能在關聯式資料來源的環境定義中使用。 quantile ( numeric_expression , numeric_expression [ at expression { , expression } ] [ <for-option> ] [ prefilter ] ) quantile (  numeric_expression , numeric_expression [ <for-option> ] [ prefilter ] ) <for-option> ::= for expression { , expression }|for report|auto 範例:quantile ( 數量 , 4 ) 結果:會傳回數量、數量值的等級以及分成 4 個分位數群組(四分位數)的數量值。 Qty Rank Quantile (Qty, 4) ------ ------- --------------- 800 1 1 700 2 1 600 3 2 500 4 2 400 5 3 400 5 3 200 7 4 200 7 4 傳回值相對於一組值的等級,以 1(最高)到 4(最低)的整數來表示。"<for-option>" 定義函數的範圍。"at" 選項會定義彙總的層次,而且只能在關聯式資料來源的環境定義中使用。 quartile ( numeric_expression [ at expression { , expression } ] [ <for-option> ] [ prefilter ] ) quartile (  numeric_expression [ <for-option> ] [ prefilter ] ) <for-option> ::= for expression { , expression }|for report|auto 範例:quartile ( 數量 ) 結果:會傳回數量和以 1(最高)到 4(最低)的整數來表示數量值的四分位數。 Qty Quartile (Qty) ------ --------------------- 450 1 400 1 350 2 300 2 250 3 200 3 150 4 100 4 傳回選取的資料項目的等級值。排序是選用的;依預設會採用遞減順序 (DESC)。如果有兩列以上是相同的,則在等級值順序(也稱為奧林匹克等級)中會有空缺的等級。"<for-option>" 定義函數的範圍。"at" 選項會定義彙總的層次,而且只能在關聯式資料來源的環境定義中使用。Distinct 是替代表示式,它與產品早期的版本相容。空值是在最後排列等級。此函數出現在 GO 資料倉儲(分析)套件中的 2005 年前 10 大零售商樣本報告中。 rank ( expression [ ASC|DESC ] { , expression [ ASC|DESC ] } [ at expression { , expression } ] [ <for-option> ] [ prefilter ] ) rank ( [ distinct ] expression [ ASC|DESC ] { , expression [ ASC|DESC ] } [ <for-option>] [ prefilter ] ) <for-option> ::= for expression { , expression }|for report|auto 範例:rank ( 銷售額 98 ) 結果:對於每一列,傳回 1998 年歸給每個銷售代表的銷售額等級值。如果發生列與列之間相同的情況,則會跳過某些數字。 Employee Sales 98 Rank --------- --------- ------------ Gibbons 60000 1 Flertjan 50000 2 Cornel 50000 2 Smith 48000 4 依列(包括現行列)傳回一組值的流動平均值。"<for-option>" 定義函數的範圍。"at" 選項會定義彙總的層次,而且只能在關聯式資料來源的環境定義中使用。 running-average ( numeric_expression [ at expression { , expression } ] [ <for-option> ] [ prefilter ] ) running-average (  numeric_expression [ <for-option> ] [ prefilter ] ) <for-option> ::= for expression { , expression }|for report|auto 範例:running-average ( 數量 ) 結果:對於每一列,傳回數量和現行以及之前的列的流動平均值。 Name Qty Avg Running-Average for name ------- ------ ------ ----------------------- Smith 7 5 7 Smith 3 5 5 Smith 6 5 5.33 Smith 4 5 5 Wong 3 4 3 Wong 5 4 4 依列(包括現行列)傳回一組值的流動計數。"<for-option>" 定義函數的範圍。"at" 選項會定義彙總的層次,而且只能在關聯式資料來源的環境定義中使用。 running-count ( numeric_expression [ at expression { , expression } ] [ <for-option> ] [ prefilter ] ) running-count (  numeric_expression [ <for-option> ] [ prefilter ] ) <for-option> ::= for expression { , expression }|for report|auto 範例:running-count ( 數量 ) 結果:對於每一列,傳回數量和現行列位置的流動計數。 Name Qty Count Running-Count for name ------- ------ --------- ------------------------ Smith 7 4 1 Smith 3 4 2 Smith 6 4 3 Smith 4 4 4 Wong 3 3 1 Wong 5 3 2 依列傳回一組值的流動差額,此差額是現行列的值與前一列(包括現行列)的值之間的差額。"<for-option>" 定義函數的範圍。"at" 選項會定義彙總的層次,而且只能在關聯式資料來源的環境定義中使用。 running-difference ( numeric_expression [ at expression { , expression } ] [ <for-option> ] [ prefilter ] ) running-difference (  numeric_expression [ <for-option> ] [ prefilter ] ) <for-option> ::= for expression { , expression }|for report|auto 範例:running-difference ( 數量 ) 結果:對於每一列,傳回數量和現行列的值與前一列的值之間的流動差額。 Name Qty Running-Difference for name ------- ------ --------------------------- Smith 7 NULL Smith 3 -4 Smith 6 3 Smith 4 -2 Wong 3 -1 Wong 5 2 依列(包括現行列)傳回一組值的流動最大值。"<for-option>" 定義函數的範圍。"at" 選項會定義彙總的層次,而且只能在關聯式資料來源的環境定義中使用。 running-maximum (  numeric_expression [ at expression { , expression } ] [ <for-option> ] [ prefilter ] ) running-maximum (  numeric_expression [ <for-option> ] [ prefilter ] ) <for-option> ::= for expression { , expression }|for report|auto 範例:running-maximum ( 數量 ) 結果:對於每一列,傳回數量和現行以及之前的列的流動最大值。 Name Qty Max Running-Maximum (Qty) for name ------- ------ ------ ------------------------- Smith 2 7 2 Smith 3 7 3 Smith 6 7 6 Smith 7 7 7 Wong 3 5 3 Wong 5 5 5 依列(包括現行列)傳回一組值的流動最小值。"<for-option>" 定義函數的範圍。"at" 選項會定義彙總的層次,而且只能在關聯式資料來源的環境定義中使用。 running-minimum ( numeric_expression [ at expression { , expression } ] [ <for-option> ] [ prefilter ] ) running-minimum (  numeric_expression [ <for-option> ] [ prefilter ] ) <for-option> ::= for expression { , expression }|for report|auto 範例:running-minimum ( 數量 ) 結果:對於每一列,傳回數量和現行以及之前的列的流動最小值。 Name Qty Min Running-Minimum (Qty) for name ------- ----- ------ -------------------------- Smith 7 2 7 Smith 3 2 3 Smith 6 2 3 Smith 2 2 2 Wong 4 3 4 Wong 5 3 4 依列(包括現行列)傳回一組值的執行總計。"<for-option>" 定義函數的範圍。"at" 選項會定義彙總的層次,而且只能在關聯式資料來源的環境定義中使用。 running-total ( numeric_expression [ at expression { , expression } ] [ <for-option> ] [ prefilter ] ) running-total (  numeric_expression [ <for-option> ] [ prefilter ] ) <for-option> ::= for expression { , expression }|for report|auto 範例:running-total ( 數量 ) 結果:對於每一列,傳回數量和現行以及之前的列的執行總計。 Name Qty Total Running-Total (Qty) for name ------- ------ -------- ------------------------- Smith 2 18 2 Smith 3 18 5 Smith 6 18 11 Smith 7 18 18 Wong 3 12 3 Wong 5 12 8 傳回選取的資料項目的標準差。 standard-deviation (  expression [ auto ] ) standard-deviation (  expression for [ all|any ] expression { , expression } ) standard-deviation (  expression for report ) 範例:standard-deviation ( 產品成本 ) 結果:傳回一個值,此值可指出產品成本與平均產品成本之間的偏差值。 計算總體標準差,並傳回總體變異數的平方根。 standard-deviation-pop (  expression [ auto ] ) standard-deviation-pop (  expression for [ all|any ] expression { , expression } ) standard-deviation-pop (  expression for report ) 範例:standard-deviation-pop ( 產品成本 ) 結果:傳回總體變異數的平方根值。 計算樣本標準差,並傳回總體變異數的平方根。 standard-deviation-samp (  expression [ auto ] ) standard-deviation-samp (  expression for [ all|any ] expression { , expression } ) standard-deviation-samp (  expression for report ) 範例:standard-deviation-samp ( ProductCost ) 結果:傳回樣本變異數的平方根值。 傳回值相對於一組值的等級,以「高」、「中」或「低」表示。 tertile (  expression [ auto ] ) tertile (  expression for [ all|any ] expression { , expression } ) tertile (  expression for report ) 範例:tertile ( 數量 ) 結果:傳回數量、分成三分位數的數量值分位數,以及分成三分位數的數量值。 Qty Quantile (Qty, 3) Tertile (Qty) ------ ------------------------ ------------------ 800 1 H 700 1 H 500 2 M 400 2 M 200 3 L 200 3 L 傳回選取的資料項目的總值。Distinct 是替代表示式,它與產品早期的版本相容。此函數出現在 GO 資料倉儲(分析)套件中的預算與實際樣本報告中。 total ( [ distinct ] expression [ auto ] ) total ( [ distinct ] expression for [ all|any ] expression { , expression } ) total ( [ distinct ] expression for report ) 範例:total ( 銷售額 ) 結果:傳回所有「銷售額」值的總值。 統計函數 此清單包含統計本質的預先定義摘要函數。 傳回選取的資料項目的變異數。 variance (  expression [ auto ] ) variance (  expression for [ all|any ] expression { , expression } ) variance (  expression for report ) 範例:variance ( 產品成本 ) 結果:傳回一個值,此值可指出產品成本與平均產品成本之間相差多遠。 傳回一組數字在捨棄此集中的空值之後的總體變異數。 variance-pop (  expression [ auto ] ) variance-pop (  expression for [ all|any ] expression { , expression } ) variance-pop (  expression for report ) 範例:variance-pop ( 數量 ) 結果:對於每一列,會傳回一組數字在捨棄此集中的空值之後的總體變異數。 傳回一組數字在捨棄此集中的空值之後的樣本變異數。 variance-samp (  expression [ auto ] ) variance-samp (  expression for [ all|any ] expression { , expression } ) variance-samp (  expression for report ) 範例:variance-samp ( Qty ) 結果:對於每一列,會傳回一組數字在捨棄此集中的空值之後的樣本變異數。 corr ( numeric_expression1 ,  numeric_expression2  [ auto ] ) corr ( numeric_expression1 ,  numeric_expression2 for [ all|any ] expression { , expression } ) corr ( numeric_expression1 ,  numeric_expression2 for report ) 傳回一組數字配對的相關性係數。計算如下: COVAR_POP(numeric_expression1, numeric_expression2) / (STDDEV_POP(numeric_expression1) * STDDEV_POP(numeric_expression2)) 範例:corr ( Cost ,  Margin  for report) 結果:介於「成本」及「利潤率」之間的相關性係數。 Cost Margin corr (Cost, Margin for report) ------- ---------- ----------------------------------------- 4 0.33 0.0872648 5 0.28 0.0872648 9.22 0.23 0.0872648 15.93 0.28 0.0872648 34.97 0.3 0.0872648 covariance-pop ( numeric_expression1 ,  numeric_expression2 ) covariance-pop ( numeric_expression1 ,  numeric_expression2 for [ all|any ] expression { , expression } ) covariance-pop ( numeric_expression1 ,  numeric_expression2 for report ) 傳回一組數字配對的總體共變異。 範例:covariance-pop ( Cost ,  Margin  for report) 結果:介於「成本」及「利潤率」之間的總體共變異。 Cost Margin covariance-pop (Cost, Margin for report) ------- ---------- --------------------------------------------------------- 4 0.33 0.032384 5 0.28 0.032384 9.22 0.23 0.032384 15.93 0.28 0.032384 34.97 0.3 0.032384 covariance-samp ( numeric_expression1 ,  numeric_expression2 ) covariance-samp ( numeric_expression1 ,  numeric_expression2 for [ all|any ] expression { , expression } ) covariance-samp ( numeric_expression1 ,  numeric_expression2 for report ) 傳回一組數字配對的樣本共變異。 範例:covariance-samp ( Cost ,  Margin  for report) 結果:介於「成本」及「利潤率」之間的樣本共變異。 Cost Margin covariance-samp (Cost, Margin for report) ------- ---------- ------------------------------------------------------------ 4 0.33 0.04048 5 0.28 0.04048 9.22 0.23 0.04048 15.93 0.28 0.04048 34.97 0.3 0.04048 regression-average-x ( numeric_expression1 ,  numeric_expression2 ) regression-average-x ( numeric_expression1 ,  numeric_expression2 for [ all|any ] expression { , expression } ) regression-average-x ( numeric_expression1 ,  numeric_expression2 for report ) 傳回回歸線之自變數 (numeric_expression2) 的平均值。 範例:regression-average-x ( Cost ,  Margin  for report) 結果:針對「成本」及「利潤率」,回歸線內的「利潤率」平均值。 Cost Margin regression-average-x (Cost, Margin for report) ------- ---------- ----------------------------------------------------------------- 4 0.33 0.284 5 0.28 0.284 9.22 0.23 0.284 15.93 0.28 0.284 34.97 0.3 0.284 regression-average-y ( numeric_expression1 ,  numeric_expression2 ) regression-average-y ( numeric_expression1 ,  numeric_expression2 for [ all|any ] expression { , expression } ) regression-average-y ( numeric_expression1 ,  numeric_expression2 for report ) 傳回回歸線之應變數 (numeric_expression1) 的平均值。 範例:regression-average-y ( Cost ,  Margin  for report) 結果:針對「成本」及「利潤率」,回歸線內的「成本」平均值。 Cost Margin regression-average-y (Cost, Margin for report) ------- ---------- ----------------------------------------------------------------- 4 0.33 13.824 5 0.28 13.824 9.22 0.23 13.824 15.93 0.28 13.824 34.97 0.3 13.824 regression-count ( numeric_expression1 ,  numeric_expression2 ) regression-count ( numeric_expression1 ,  numeric_expression2 for [ all|any ] expression { , expression } ) regression-count ( numeric_expression1 ,  numeric_expression2 for report ) 傳回用於填滿回歸線的非空值號碼數。 範例:regression-count ( Cost ,  Margin  for report) 結果:針對「成本」及「利潤率」,用來填滿回歸線的非空值號碼數。 Cost Margin regression-count (Cost, Margin for report) ------- ---------- ----------------------------------------------------------- 4 0.33 5 5 0.28 5 9.22 0.23 5 15.93 0.28 5 34.97 0.3 5 regression-intercept ( numeric_expression1 ,  numeric_expression2 ) regression-intercept ( numeric_expression1 ,  numeric_expression2 for [ all|any ] expression { , expression } ) regression-intercept ( numeric_expression1 ,  numeric_expression2 for report ) 傳回回歸線的 y 攔截。計算如下: AVG(numeric_expression1) - REGR_SLOPE(numeric_expression1, numeric_expression2) * AVG(numeric_expression2) 範例:regression-intercept ( Cost ,  Margin  for report) 結果:針對「成本」及「利潤率」,回歸線的 y 截距。 Cost Margin regression-intercept (Cost, Margin for report) ------- ---------- ---------------------------------------------------------------- 4 0.33 5.18015038 5 0.28 5.18015038 9.22 0.23 5.18015038 15.93 0.28 5.18015038 34.97 0.3 5.18015038 regression-r2 ( numeric_expression1 ,  numeric_expression2 ) regression-r2 ( numeric_expression1 ,  numeric_expression2 for [ all|any ] expression { , expression } ) regression-r2 ( numeric_expression1 ,  numeric_expression2 for report ) 傳回回歸線判定的係數(也稱為 "R-squared" 或 "goodness of fit")。此值會根據下列條件來計算: IF VAR_POP(numeric_expression2) = 0 THEN NULL IF VAR_POP(numeric_expression1) = 0 AND VAR_POP(numeric_expression2) <> 0 THEN 1 IF VAR_POP(numeric_expression1) > 0 and VAR_POP(numeric_expression2) <> 0 THEN POWER(CORR (numeric_expression1, numeric_expression2)) 範例:regression-r2 ( Cost ,  Margin  for report) 結果:針對「成本」及「利潤率」,回歸線的判定係數。 Cost Margin regression-r2 (Cost, Margin for report) ------- ---------- ------------------------------------------------------ 4 0.33 0.00761514 5 0.28 0.00761514 9.22 0.23 0.00761514 15.93 0.28 0.00761514 34.97 0.3 0.00761514 regression-slope ( numeric_expression1 ,  numeric_expression2 ) regression-slope ( numeric_expression1 ,  numeric_expression2 for [ all|any ] expression { , expression } ) regression-slope ( numeric_expression1 ,  numeric_expression2 for report ) 傳回回歸線的範圍。計算如下: COVAR_POP(numeric_expression1,numeric_expression2) / VAR_POP(numeric_expression2) 範例:regression-slope ( Cost ,  Margin ) 結果:針對「成本」及「利潤率」,回歸線的斜率。 Cost Margin regression-slope (Cost, Margin for report) ------- ---------- ----------------------------------------------------------- 4 0.33 30.43609023 5 0.28 30.43609023 9.22 0.23 30.43609023 15.93 0.28 30.43609023 34.97 0.3 30.43609023 regression-sxx ( numeric_expression1 ,  numeric_expression2 ) regression-sxx ( numeric_expression1 ,  numeric_expression2 for [ all|any ] expression { , expression } ) regression-sxx ( numeric_expression1 ,  numeric_expression2 for report ) 刪除 NULL 配對之後,傳回下列計算: REGR_COUNT(numeric_expression1, numeric_expression2) * VAR_POP(numeric_expression2) 範例:regression-sxx ( Cost ,  Margin  for report) 結果:針對「成本」及「利潤率」,回歸線的 sxx 計算。 Cost Margin regression-sxx (Cost, Margin for report) ------- ---------- --------------------------------------------------------- 4 0.33 0.00532 5 0.28 0.00532 9.22 0.23 0.00532 15.93 0.28 0.00532 34.97 0.3 0.00532 regression-sxy ( numeric_expression1 ,  numeric_expression2 ) regression-sxy ( numeric_expression1 ,  numeric_expression2 for [ all|any ] expression { , expression } ) regression-sxy ( numeric_expression1 ,  numeric_expression2 for report ) 刪除 NULL 配對之後,傳回下列計算: REGR_COUNT(numeric_expression1, numeric_expression2) * COVAR_POP(numeric_expression1, numeric_expression2) 範例:regression-sxy ( Cost ,  Margin  for report) 結果:針對「成本」及「利潤率」,回歸線的 sxy 計算。 Cost Margin regression-sxy (Cost, Margin for report) ------- ---------- --------------------------------------------------------- 4 0.33 0.16192 5 0.28 0.16192 9.22 0.23 0.16192 15.93 0.28 0.16192 34.97 0.3 0.16192 regression-syy ( numeric_expression1 ,  numeric_expression2 ) regression-syy ( numeric_expression1 ,  numeric_expression2 for [ all|any ] expression { , expression } ) regression-syy ( numeric_expression1 ,  numeric_expression2 for report ) 刪除 NULL 配對之後,傳回下列計算: REGR_COUNT(numeric_expression1, numeric_expression2) * VAR_POP(numeric_expression1) 範例:regression-syy ( Cost ,  Margin  for report) 結果:針對「成本」及「利潤率」,回歸線的 syy 計算。 Cost Margin regression-syy (Cost, Margin for report) ------- ---------- --------------------------------------------------------- 4 0.33 647.15932 5 0.28 647.15932 9.22 0.23 647.15932 15.93 0.28 647.15932 34.97 0.3 647.15932 成員摘要 此清單包含預先定義的函數,這些函數會傳回一組成員的單一摘要值,或針對一組成員中的每個成員傳回不同的摘要值。
錯誤 您的表示式中的強調顯示記號處發生錯誤。
建構 此清單包含可用來建立表示式的建構和範本。範本會將多個函數合併成一個群組。例如,搜尋 case 範本包括 case、when、else 和 end 函數。 搜尋 case 此建構是搜尋 case 的範本,包括 CASE、WHEN、ELSE,及 END 函數。 CASE WHEN [國家] = '加拿大' THEN ([標價] * 0.60) WHEN [國碼] > 100 THEN [標價] * 0.80 ELSE [標價] END 簡單 case 此建構是簡單 case 的範本,包括 CASE、WHEN、ELSE,及 END 函數。 CASE [國家] WHEN '加拿大' THEN ([標價] * 0.60) WHEN '澳大利亞' THEN [標價] * 0.80 ELSE [標價] END if then else 此建構是用於 if...then...else 陳述式的範本。此建構出現在 GO 資料倉儲(分析)套件中的 2005 年前 10 大零售商樣本報告中。 IF ([國家] = '加拿大') THEN ([標價] * 0.60) ELSE ([標價]) in_range 這是用於 in_range 表示式的範本。 [代碼] IN_RANGE { :30 , 40, 50, 999: } 範例:[代碼] IN_RANGE { 5 } 結果:這相當於 [代碼] = 5。 範例:[代碼] IN_RANGE { 5: } 結果:這相當於 [代碼] >= 5。 範例:[代碼] IN_RANGE { :5 } 結果:這相當於 [代碼] <= 5。 範例:[代碼] IN_RANGE { 5:10 } 結果:這相當於 ( [代碼] >= 5 and [代碼] <= 10 )。 範例:[代碼] IN_RANGE { :5,10,20: } 結果:這相當於 ( [代碼] <= 5 or [代碼] = 10 or [代碼] >= 20 )。
期間述詞 此清單包含的述詞可以用來比較期間表示式。 contains 如果 "period_expression1" 包含 "period_expression2",則傳回 "true";亦即,如果第一個期間包含日期時間值,或第二個期間所含的所有值,則傳回 "true"。 period_expression1 contains ( period_expression2 | datetime_expression ) period( 1989-11-01, 1991-05-19 ) contains period( 1991-05-19, 1991-06-04 ) 結果:false period( 1989-11-01, 1991-05-19 ) contains period( 1990-05-19, 1991-04-04 ) 結果:true period( 1989-11-01, 1991-05-19 ) contains 1991-04-04 結果:true equals 如果 "period_expression1" 和 "period_expression2" 具有相同的期間開始值及期間結束值,則傳回 "true"。 period_expression1 equals period_expression2 period( 1989-11-01, 1991-05-19 ) equals period( 1989-11-01, 1991-05-19 ) 結果:true immediately precedes 如果 "period_expression1" 緊跟在 "period_expression2" 之前,則傳回 "true";亦即,第一個期間的結束值等於第二個期間的開始值。 period_expression1 immediately precedes period_expression2 period( 1989-11-01, 1991-05-19 ) immediately precedes period( 1991-05-19, 1991-06-04 ) 結果:true period( 1989-11-01, 1991-05-18 ) immediately precedes period( 1991-05-19, 1991-06-04 ) 結果:false immediately succeeds 如果 "period_expression1" 緊跟在 "period_expression2" 之後,則傳回 "true";亦即,第一個期間的開始值等於第二個期間的結束值。 period_expression1 immediately succeeds period_expression2 period( 1991-05-19, 1994-01-10 ) immediately succeeds period( 1991-01-19, 1991-05-19 ) 結果:true period( 1991-05-19, 1994-01-10 ) 緊跟在 period( 1991-01-20, 1991-05-18 ) 之後 結果:false overlaps 如果 "period_expression1" 與 "period_expression2" 重疊,則傳回 "true";亦即,至少有一個共同的值。 period_expression1 overlaps period_expression2 period( 1991-05-19, 1994-01-10 ) 與 period( 1993-01-19, 1995-05-19 ) 重疊 結果:true precedes 如果 "period_expression1" 在 "period_expression2" 之前,則傳回 "true";亦即,第一個期間中包含的所有值都小於或等於第二個期間的開始值。 period_expression1 precedes period_expression2 period( 1989-11-01, 1991-05-19 ) precedes period( 1991-05-19, 1991-06-04 ) 結果:true period( 1989-11-01, 1991-05-18 ) precedes period( 1991-05-19, 1991-06-04 ) 結果:true succeeds 如果 "period_expression1" 在 "period_expression2" 之後,則傳回 "true";亦即,第一個期間中包含的所有值都大於或等於第二個期間的結束值。 period_expression1 succeeds period_expression2 period( 1991-05-19, 1994-01-10 ) succeeds period( 1991-01-19, 1991-05-19 ) 結果:true period( 1991-05-20, 1994-01-10 ) succeeds period( 1991-01-20, 1991-05-19 ) 結果:true
商業日期/時間函數 此清單包含用來執行日期和時間計算的商業函數。 _add_seconds ( time_expression, integer_expression ) 根據將 "integer_expression" 秒加到 "time_expression" 所產生的 "time_expression" 格式,傳回時間或日期時間。 範例:_add_seconds ( 13:04:59 , 1 ) 結果:13:05:00 範例:_add_seconds ( 2002-04-30 12:10:10.000, 1 ) 結果:2002-04-30 12:10:11.000 範例:_add_seconds ( 2002-04-30 00:00:00.000, 1/100 ) 請注意,第二個引數不是整數。這有受到某些資料庫技術支援,並可增加時間部分。 結果:2002-04-30 00:00:00.010 _add_minutes ( time_expression, integer_expression ) 根據將 "integer_expression" 分鐘加到 "time_expression" 所產生的 "time_expression" 格式,傳回時間或日期時間。 範例:_add_minutes ( 13:59:00 , 1 ) 結果:14:00:00 範例:_add_minutes ( 2002-04-30 12:59:10.000, 1 ) 結果:2002-04-30 13:00:10.000 範例:_add_minutes ( 2002-04-30 00:00:00.000, 1/60 ) 請注意,第二個引數不是整數。這有受到某些資料庫技術支援,並可增加時間部分。 結果:2002-04-30 00:00:01.000 _add_hours ( time_expression, integer_expression ) 根據將 "integer_expression" 小時加到 "time_expression" 所產生的 "time_expression" 格式,傳回時間或日期時間。 範例:_add_hours ( 13:59:00 , 1 ) 結果:14:59:00 範例:_add_hours ( 2002-04-30 12:10:10.000, 1 ) 結果:2002-04-30 13:10:10.000, 範例:_add_hours ( 2002-04-30 00:00:00.000, 1/60 ) 請注意,第二個引數不是整數。這有受到某些資料庫技術支援,並可增加時間部分。 結果:2002-04-30 00:01:00.000 _add_days ( date_expression, integer_expression ) 根據將 "integer_expression" 天數加到 "date_expression" 所產生的 "date_expression" 格式,傳回日期或日期時間。 範例:_add_days ( 2002-04-30 , 1 ) 結果:2002-05-01 範例:_add_days ( 2002-04-30 12:10:10.000, 1 ) 結果:2002-05-01 12:10:10.000 範例:_add_days ( 2002-04-30 00:00:00.000, 1/24 ) 請注意,第二個引數不是整數。這有受到某些資料庫技術支援,並可增加時間部分。 結果:2002-04-30 01:00:00.000 _add_months ( date_expression, integer_expression ) 新增 "integer_expression" 月至 "date_expression"。若結果月比日期元件較少天數,則會傳回結果月的最後一天。在所有其他案例中,回覆值有與 "date_expression" 相同的日期元件。 範例:_add_months ( 2012-04-15 , 3 ) 結果:2012-07-15 結果不是結果月的最後一天。 範例:_add_months ( 2012-02-29 , 1 ) 結果:2012-03-29 使用函數 _last_of_month 來返回月的最後一天。 範例:_last_of_month ( _add_months ( 2012-02-29 , 1 ) ) 結果:2012-03-31 調整日為結果月的最後一天。 範例:_add_months ( 2012-01-31 , 1 ) 結果:2012-02-29 新增至時間戳記。 範例:_add_months ( 2002-04-30 12:10:10.000 , 1 ) 結果:2002-05-30 12:10:10.000 _add_years ( date_expression, integer_expression ) 新增 "integer_expression" 年至 "date_expression"。若 "date_expression" 為 2 月 29 日,並且結果年為非閏年,則結果日要設為 2 月 28 日。在所有其他案例中,回覆值有與 "date_expression" 相同的日期與月份。 範例:_add_years ( 2012-04-15 , 1 ) 結果:2013-04-15 針對非閏年 來調整 2 月 29 日。 範例:_add_years ( 2012-02-29 , 1 ) 結果:2013-02-28 新增至時間戳記。 範例:_add_years ( 2002-04-30 12:10:10.000 , 1 ) 結果:2003-04-30 12:10:10.000 _age ( date_expression ) 傳回從今天的日期中減掉 "date_expression" 後得到的數字。傳回的值的格式為 YYYYMMDD,其中 YYYY 代表年數,MM 代表月數,DD 代表天數。 範例:_age ( 1990-04-30 )(如果今天的日期是 2003-02-05) 結果:120906,代表 12 年 9 個月又 6 天。 _date_to_int ( date_expression ) 傳回 "date_expression" 的整數表示法。傳回的值的格式為 YYYYMMDD,其中 YYYY 代表年數,MM 代表月數,DD 代表天數。 範例:_date_to_int ( 2003-01-01 ) 結果:20030101 _day_of_week ( date_expression, integer ) 傳回星期幾(1 至 7),其中 1 是一週的第一天,如第二個參數所指出的(1 至 7,1 是星期一,而 7 是星期日)。請注意,在 ISO 8601 標準中,一週是從星期一開始當作第一天。 範例:_day_of_week ( 2003-01-01 , 1 ) 結果:3 _day_of_year ( date_expression ) 傳回 "date_expression" 中的那一年的天數(1 到 366)。也稱為儒略日。 範例:_day_of_year ( 2003-03-01 ) 結果:61 _days_between ( date_expression1 , date_expression2 ) 傳回正數或負數,此值代表 "date_expression1" 和 "date_expression2" 之間的天數。如果 "date_expression1" < "date_expression2",則結果將會是負數。 範例:_days_between ( 2002-06-21 , 2002-04-30 ) 結果:52 範例:_days_between ( 2002-04-30 , 2002-06-21 ) 結果:-52 _days_to_end_of_month ( date_expression ) 傳回一個數字,代表在 "date_expression" 所呈現的月份中的剩餘天數。 範例:_days_to_end_of_month ( 2002-04-20 14:30:22.123 ) 結果:10 _first_of_month ( date_expression ) 根據引數,將 "date_expression" 轉換為同年同月的第 1 天的日期,傳回日期或日期時間。 範例:_first_of_month ( 2002-04-20 ) 結果:2002-04-01 範例:_first_of_month ( 2002-04-20 12:10:10.000 ) 結果:2002-04-01 12:10:10.000 _last_of_month ( date_expression ) 根據引數(此引數是 "date_expression" 所呈現的月份的最後一天),傳回日期或日期時間。 範例:_last_of_month ( 2002-01-14 ) 結果:2002-01-31 範例:_last_of_month ( 2002-01-14 12:10:10.000 ) 結果:2002-01-31 12:10:10.000 _make_timestamp ( integer_expression1, integer_expression2, integer_expression3 ) 傳回一個時間戳記,此時間戳記是由 "integer_expression1"(年)、"integer_expression2"(月)及"integer_expression3"(日)構成。時間部分的預設值是 00:00:00.000。 範例:_make_timestamp ( 2002 , 01 , 14 ) 結果:2002-01-14 00:00:00.000 _months_between ( date_expression1, date_expression2 ) 傳回正整數或負整數,代表 "date_expression1" 和 "date_expression2" 之間的月數。如果 "date_expression1" 早於 "date_expression2",則會傳回負數。 範例:_months_between ( 2002-04-03 , 2002-01-30 ) 結果:2 範例:_months_between ( 2002-01-30 , 2002-04-03 ) 結果:-2 _shift_timezone ( timestamp_value , from_time_zone , target_time_zone ) _shift_timezone ( timestamp_with_time_zone_value , target_time_zone ) 將時間戳記值從一個時區移位至另一個時區。適用時,此功能會允許使用「日光節約時間」。若第一個引數是「時間戳記」類型,則第二個及第三個引數會分別代表「來源」及「目標」時區。若第一個引數是具有時區的「時間戳記」類型,則「來源」時區已經隱含於第一個引數中,因此第二個引數會代表「目標」時區。第一個引數得資料類型也將決定回覆值的資料類型。第二個及第三個引數是「字串」類型,並且代表時區 ID。可以在下面找到這些 ID 的清單。 附註:使用此功能將造成本端處理。 範例:_shift_timezone( 2013-06-30 12:00:00 , '美洲/紐約' , 'GMT' ) 結果:2013-06-30 16:00:00 範例:_shift_timezone( 2013-11-30 12:00:00-05:00 , '美洲/溫哥華' ) 結果:2013-11-30 09:00:00-08:00 時區 ID: GMT (GMT+00:00) Greenwich Mean Time Europe/Lisbon (GMT+00:00) Portugal Time (Lisbon) Europe/Amsterdam (GMT+01:00) Netherlands Time Europe/Paris (GMT+01:00) France Time Europe/Berlin (GMT+01:00) Germany Time Europe/Brussels (GMT+01:00) Belgium Time Europe/Rome (GMT+01:00) Italy Time Europe/Vienna (GMT+01:00) Austria Time Africa/Cairo (GMT+02:00) Egypt Time Africa/Johannesburg (GMT+02:00) South Africa Time Europe/Athens (GMT+02:00) Greece Time Africa/Addis_Ababa (GMT+03:00) Ethiopia Time Asia/Dubai (GMT+04:00) United Arab Emirates Time Asia/Karachi (GMT+05:00) Pakistan Time Asia/Calcutta (GMT+05:30) India Time Asia/Dhaka (GMT+06:00) Bangladesh Time Asia/Saigon (GMT+07:00) Vietnam Time Asia/Hong_Kong (GMT+08:00) Hong Kong SAR China Time Asia/Tokyo (GMT+09:00) Japan Time Australia/Darwin (GMT+09:30) Australia Time (Darwin) Australia/Sydney (GMT+10:00) Australia Time (Sydney) Pacific/Guadalcanal (GMT+11:00) Solomon Islands Time America/Argentina/San_Juan (GMT-03:00) Argentina Time (San Juan) America/Buenos_Aires (GMT-03:00) Argentina Time (Buenos Aires) America/Sao_Paulo (GMT-03:00) Brazil Time (Sao Paulo) America/St_Johns (GMT-03:30) Canada Time (St. John’s) America/Puerto_Rico (GMT-04:00) Puerto Rico Time America/New_York (GMT-05:00) United States Time (New York) America/Toronto (GMT-05:00) Canada Time (Toronto) America/Jamaica (GMT-05:00) Jamaica Time America/Chicago (GMT-06:00) United States Time (Chicago) America/Mexico_City (GMT-06:00) Mexico Time (Mexico City) America/Cambridge_Bay (GMT-07:00) Canada Time (Cambridge Bay) America/Edmonton (GMT-07:00) Canada Time (Edmonton) America/Yellowknife (GMT-07:00) Canada Time (Yellowknife) America/Denver (GMT-07:00) United States Time (Denver) America/Chihuahua (GMT-07:00) Mexico Time (Chihuahua) America/Los_Angeles (GMT-08:00) United States Time (Los Angeles) America/Tijuana (GMT-08:00) Mexico Time (Tijuana) America/Vancouver (GMT-08:00) Canada Time (Vancouver) America/Anchorage (GMT-09:00) United States Time (Anchorage) Pacific/Honolulu (GMT-10:00) United States Time (Honolulu) Pacific/Tahiti (GMT-10:00) French Polynesia Time (Tahiti) Pacific/Midway (GMT-11:00) U.S. Minor Outlying Islands Time (Midway) Pacific/Niue (GMT-11:00) Niue Time 可能也會使用自訂的時區 ID,使用格式 GMT(+|-)HH:MM。例如,GMT-06:30 或 GMT+02:00。 _week_of_year ( date_expression ) 根據 ISO 8601 標準,傳回 "date_expression" 在當年度是第幾週。年度第 1 週是指包含星期四的第一週,意思相等於是包含 1 月 4 日的第一週。一週是從星期一(日 1)開始,到星期日(日 7)結束。 範例:_week_of_year ( 2003-01-01 ) 結果:1 _years_between ( date_expression1, date_expression2 ) 傳回正整數或負整數,代表 "date_expression1" 和 "date_expression2" 之間的年數。如果 "date_expression1" < "date_expression2",則會傳回負值。 範例:_years_between ( 2003-01-30 , 2001-04-03 ) 結果:1 範例:_years_between ( 2001-04-03 , 2003-01-30 ) 結果:-1 _ymdint_between ( date_expression1 , date_expression2 ) 傳回一個數字,代表 "date_expression1" 和 "date_expression2" 之間的差額。傳回的值的格式為 YYYYMMDD,其中 YYYY 代表年數,MM 代表月數,DD 代表天數。 範例:_ymdint_between ( 1990-04-30 , 2003-02-05 ) 結果:120905,代表 12 年 9 個月又 5 天。 _year ( date_expression ) 傳回 "date_expression" 中年欄位的值。 範例:_year ( 2003-03-01 ) 結果:2003 _month ( date_expression ) 傳回 "date_expression" 中月欄位的值。 範例:_month ( 2003-03-01 ) 結果:3 _day ( date_expression ) 傳回 "date_expression" 中日欄位的值。 範例:_day ( 2003-03-01 ) 結果:1 _hour ( date_expression ) 傳回 "date_expression" 中小時欄位的值。 範例:_hour ( 2002-01-31 12:10:10.254 ) 結果:12 _minute ( date_expression ) 傳回 "date_expression" 中分鐘欄位的值。 範例:_minute ( 2002-01-31 12:10:10.254 ) 結果:10 _second ( date_expression ) 傳回 "date_expression" 中秒欄位的值。 範例:_second ( 2002-01-31 12:10:10.254 ) 結果:10.254 _timezone_hour ( timestamp_with_time_zone_value ) _timezone_hour ( time_with_time_zone_value ) 傳回表示式中時區小時欄位的值。表示式必須為 "timestamp with time zone" 或 "time with time zone" 類型。 範例:_timezone_hour ( 2002-01-31 12:10:10.254-05:30 ) 結果:-5 _timezone_minute ( timestamp_with_time_zone_value ) _timezone_minute ( time_with_time_zone_value ) 傳回表示式中時區分鐘欄位的值。表示式必須為 "timestamp with time zone" 或 "time with time zone" 類型。 範例:_timezone_minute ( 2002-01-31 12:10:10.254-05:30 ) 結果:-30 _start_of_day ([ date_expression ]) 傳回 "date_expression" 的開始時間或今天的開始時間作為時間戳記 範例:_start_of_day ( 2014-11-23 12:10:10.254 ) 結果:2014-11-23 00:00:00 範例:_start_of_day () 結果:2016-01-01 00:00:00 _end_of_day ([ date_expression ]) 傳回 "date_expression" 的結束時間或今天的結束時間作為時間戳記。 範例:_end_of_day ( 2014-11-23 12:10:10.254 ) 結果:2014-11-23 23:59:59 範例:_end_of_day () 結果:2016-01-01 23:59:59 _unix_timestamp ( date_expression ) 傳回 1970-01-01 00:00:00-00 之後具有給定 "date_expression" 的秒數。 範例:_unix_timestamp ( 2014-11-23 ) 結果:1416718800 _from_unixtime ( integer_expression ) 傳回 "integer_expression" 所指定的 unix 時間作為具有時區的時間戳記。 範例:_from_unixtime (1417807335) 結果:2014-12-05 19:22:15+00:00
巨集函數 此清單包含可在巨集中使用的函數。一個巨集可包含一個以上的巨集函數。巨集會在開頭和結尾處以 # 記號作為區隔字元。位在 # 記號之間的所有內容都會被視為是巨集表示式,並且會在執行時期執行。若為接受資料類型為包含時區的時間戳記的表示式的巨集函數,可接受的格式為 'yyyy-mm-dd hh:mm:ss[.ff]+hh:mm',其中的小數秒是選用的,可使用 1 至 9 位數字來表示。也接受以字元 'T' 來替代區隔日期部分與時間部分的空格。此外,也接受以字元 'Z' 來替代時區 '+hh:mm',此字元會在內部當成 '+00:00' 來處理。會傳回資料類型為包含時區的時間戳記的表示式的巨集函數,依預設會傳回 9 位數字代表其小數秒。需要的話,可以使用巨集函數 timestampMask() 來修整輸出。 傳回將 "integer_expression" 秒數加到 "string_expression" 所產生的包含時區的時間戳記(以字串表示),其中 "string_expression" 代表包含時區的時間戳記。 _add_seconds ( string_expression , integer_expression ) 範例:# _add_seconds ( '2005-11-01 12:00:00.000-05:00' , -1 ) # 結果:2005-11-01 11:59:59.000-05:00 範例:# _add_seconds ( $current_timestamp , 1 ) # 結果:2005-11-01 12:00:01.000000000-05:00 範例:# timestampMask ( _add_seconds ( $current_timestamp , 1 ) , 'hh:mm:ss' ) # 結果:12:00:01 傳回將 "integer_expression" 分鐘數加到 "string_expression" 所產生的包含時區的時間戳記(以字串表示),其中 "string_expression" 代表包含時區的時間戳記。 _add_minutes ( string_expression , integer_expression ) 範例:# _add_minutes ( '2005-11-01 12:00:00.000-05:00' , -1 ) # 結果:2005-11-01 11:59:00.000-05:00 範例:# _add_minutes ( $current_timestamp , 1 ) # 結果:2005-11-01 12:01:00.000000000-05:00 範例:# timestampMask ( _add_minutes ( $current_timestamp , 1 ) , 'hh:mm:ss' ) # 結果:12:01:00 傳回將 "integer_expression" 小時數加到 "string_expression" 所產生的包含時區的時間戳記(以字串表示),其中 "string_expression" 代表包含時區的時間戳記。 _add_hours ( string_expression , integer_expression ) 範例:# _add_hours ( '2005-11-01 12:00:00.000-05:00' , -1 ) # 結果:2005-11-01 13:00:00.000-05:00 範例:# _add_hours ( $current_timestamp , 1 ) # 結果:2005-11-01 13:00:00.000000000-05:00 範例:# timestampMask ( _add_hours ( $current_timestamp , 1 ) , 'hh:mm:ss' ) # 結果:13:00:00 傳回將 "integer_expression" 天數加到 "string_expression" 所產生的包含時區的時間戳記(以字串表示),其中 "string_expression" 代表包含時區的時間戳記。第一個引數為日期(指定為 yyyy-mm-dd 格式的字串)時,則回覆值是格式化為日期的字串。 _add_days ( string_expression , integer_expression ) 範例:# _add_days ( '2005-11-01 12:00:00.000-05:00' , -1 ) # 結果:2005-10-31 12:00:00.000000000-05:00 範例:# _add_days ( $current_timestamp , 1 ) # 結果:2005-11-02 12:00:00.000000000-05:00 範例:# timestampMask ( _add_days ( $current_timestamp , 1 ) , 'yyyy-mm-dd' ) # 結果:2005-11-02 範例:# _add_days( '2019-11-14' , 3 ) # 結果:2019-11-17 傳回將 "integer_expression" 月數加到 "string_expression" 所產生的包含時區的時間戳記(以字串表示),其中 "string_expression" 代表包含時區的時間戳記。第一個引數為日期(指定為 yyyy-mm-dd 格式的字串)時,則回覆值是格式化為日期的字串。 _add_months ( string_expression , integer_expression ) 範例:# _add_months ( '2005-11-01 12:00:00.000-05:00' , -1 ) # 結果:2005-10-01 12:00:00.000000000-05:00 範例:# _add_months ( $current_timestamp , 1 ) # 結果:2005-12-01 12:00:00.000000000-05:00 範例:# timestampMask ( _add_months ( $current_timestamp , 1 ) , 'yyyy-mm-dd' ) # 結果:2005-12-01 範例:# _add_months( '2019-11-14' , -1 ) # 結果:2019-10-14 傳回將 "integer_expression" 年數加到 "string_expression" 所產生的包含時區的時間戳記(以字串表示),其中 "string_expression" 代表包含時區的時間戳記。第一個引數為日期(指定為 yyyy-mm-dd 格式的字串)時,則回覆值是格式化為日期的字串。 _add_years ( string_expression , integer_expression ) 範例:# _add_years ( '2005-11-01 12:00:00.000-05:00' , -1 ) # 結果:2004-11-01 12:00:00.000000000-05:00 範例:# _add_years ( $current_timestamp , 1 ) # 結果:2006-11-01 12:00:00.000000000-05:00 範例:# timestampMask ( _add_years ( $current_timestamp , 1 ) , 'yyyy-mm-dd' ) # 結果:2006-11-01 範例:# _add_years( '2019-11-14' , -2 ) # 結果:2017-11-14 _first_of_month ( string_expression ) 傳回將 "string_expression" 中的日值轉換為 1 後產生的包含時區的時間戳記(以字串表示),其中 "string_expression" 是包含時區的時間戳記。 範例:# _first_of_month ( '2005-11-11 12:00:00.000-05:00' ) # 結果:2005-11-01 12:00:00.000000000-05:00 範例:# timestampMask ( _first_of_month ( '2005-11-11 12:00:00.000-05:00' ) , 'yyyymmdd' ) # 結果:20051101 _last_of_month ( string_expression ) 傳回包含時區的時間戳記(以字串表示),此日期是 "string_expression" 代表的那個月份的最後一天,其中 "string_expression" 是包含時區的時間戳記。 範例:# _last_of_month ( '2005-11-11 12:00:00.000-05:00' ) # 結果:2005-11-30 12:00:00.000000000-05:00 範例:# timestampMask ( _last_of_month ( '2005-11-11 12:00:00.000-05:00' ) , 'yyyy-mm-dd' ) # 結果:2005-11-30 modelj ( 'identifier' [ , 'model_search_path' [ , 'options' ] ] ) 傳回部分 json 格式的 meta 資料模型。現行模型將在未指定 'model_search_path' 時使用。 'options' 引數可設為 'cleanup',這會變更固定值的部分結果(有助於測試)。 sq ( modelj ( '[gosales].[country].[country]' ) 以方括弧括住 "string_expression"。 sb ( string_expression ) 範例:# sb ( 'abc' ) # 結果:[abc] 以單引號括住 "string_expression"。 sq ( string_expression ) 範例:# sq ( 'zero' ) # 結果:'zero' 以雙引號括住 "string_expression"。 dq ( string_expression ) 範例:# dq ( 'zero' ) # 結果:"zero" 使用現行已鑑別使用者的身分資訊來查閱指定的參數對映中的值。使用者身分的每一個部分(帳戶名稱、群組名稱、角色名稱)都用來作為對映中的索引鍵。然後會以字串形式傳回從參數對映中擷取到的唯一值清單,其中每個值都是以單引號來括住,若有多個值,則會以逗點區隔。 CSVIdentityName ( %parameter_map_name [ , separator_string ] ) 範例:# CSVIdentityName ( %security_clearance_level_map ) # 結果:'level_500', 'level_501', 'level_700' 會以字串清單傳回使用者身分的各個部分(帳戶名稱、群組名稱、角色名稱)。會以字串形式傳回唯一值清單,其中每個值都是以單引號來括住,若有多個值,則會以逗點區隔。 CSVIdentityNameList ( [ separator_string ] ) 範例:# CSVIdentityNameList ( ) # 結果:'Everyone', 'Report Administrators', 'Query User' 傳回 Cognos® Access Manager 通行證。 CAMPassport ( ) 範例:# CAMPassport ( ) # 結果:111:98812d62-4fd4-037b-4354-26414cf7ebef:3677162321 會使用以逗點區隔的值清單傳回使用者的 Cognos® Access Manager ID (CAMID) 的各個部分,例如帳戶名稱、群組名稱或角色名稱。 CAMIDList ( [ separator_string ] ) 範例:#CAMIDList ( ) # 結果:CAMID ( "::Everyone" ) , CAMID ( ":Authors" ) , CAMID ( ":Query Users" ) , CAMID ( ":Consumers" ) , CAMID ( ":Metrics Authors" ) 根據身分類型(帳戶、群組或角色)傳回使用者 Cognos® Access Manager ID (CAMID) 的陣列。CAMIDListForType 可以與巨集函數 csv 或 join 一起使用。 CAMIDListForType ( identity type ) 範例:[qs].[userRole] in ( # csv ( CAMIDListForType ( 'role' ) ) # ) 結果:[qs].[userRole] in ( 'CAMID ( "::System Administrators" ) ' , 'CAMID ( ":Authors" )' ) 連結兩個字串。 value1 + value2 範例:# '{ ' + $runLocale + ' }' # 結果:{en-us} 從第一個引數刪掉前導字元。選用的第二個引數定義要刪掉的字元集。依預設,此函數會刪掉空格(例如,空格、標籤、換行,以及換行)。 lstrip ( string_expression [ , set_of_characters ] ) 範例:# sq( lstrip ( ' abc ' ) ) # 結果:'abc ' 範例:# lstrip ( ' 0053.2100 ' , '0 \t\r\n' ) # 結果:53.2100 傳回 "parameterName" 的參數值(如果已定義該參數值)。將會傳回 "defaultText" 值 (如果 "parameterName" 不存在)。當 "datatype" 設為 "string" 時,結果值會以單引號括住。 使用此函數並不會導致遺漏參數的異常狀況。 ParamValue ( parameterName [ , defaultText [, datatype ] ] ) 範例:# ParamValue ( 'p_country' ) # 結果:'Canada' - p_country 已設定 結果:null - p_country 不是已知參數 結果:null - p_country 用於選用提示且未設定 範例:# ParamValue ( 'p_country' , 'Netherlands' ) # 結果:'Canada' - p_country 已設定 結果:'Netherlands' - p_country 不是已知參數 結果:'Netherlands' - p_country 用於選用提示且未設定 範例:# ParamValue ( 'p_country', ' cast ( null as varchar(20)) ' , 'token' ) # 結果:'Canada' - p_country 已設定 結果:cast ( null as varchar(20)) - p_country 不是已知參數 結果:cast ( null as varchar(20)) - p_country 用於選用提示且未設定 提示使用者輸入單一值或成員。只有 "prompt_name" 是必要項目。若沒有指定資料類型,則預設的資料類型為 'string'。若有指定 "defaultText",提示便為選用的。若有指定 "Text",此文字將會顯示在值的前面。可將 "QueryItem" 指定為使用 "queryItem" 的提示資訊內容。若有指定 "Trailing_text",此文字將會附加至值的後面。資料類型為 'memberuniquename' 時,則會建立單一選取成員提示。最好是提供預設值,作為第三個引數。預設值必須是有效的成員唯一名稱;它也可以是別名,其參照 Report Studio 中所完成的成員唯一名稱。 prompt ( prompt_name , datatype , defaultText , text , queryItem , trailing_text ) 範例:select . . . where COUNTRY_MULTILINGUAL.COUNTRY_CODE > #prompt ( 'Starting CountryCode' , 'integer' , '10' ) # 結果:select . . . where COUNTRY_MULTILINGUAL.COUNTRY_CODE > 10 範例:[gosales].[國家].[國家] = # prompt ( 'countryPrompt' , 'string' , '''加拿大''' ) # 結果:[gosales].[國家].[國家] = '加拿大' 範例:set ( #prompt ('myProduct', 'memberuniquename', '[Camping Equipment]', '', '[Sales].[Product].[Product].[Product line]')#) 結果:set([Sales].[Product].[Product].[Product line]->[all].[1]) 必須指定 "defaultText" 參數,使它在巨集環境定義中實際有效,因為不會對此值進行格式化。範例 2 中的預設字串 '''加拿大''' 被指定為使用單引號的字串,其中嵌入的單引號會加倍,因此變成 3 個引號。這樣可以使字串在表示式中正確地顯示在單引號中。依 string 資料類型的一般規則,應一律按照此方式來指定 "defaultText",但在儲存程序參數的環境定義中除外。若為 'date' 或 'datetime' 類型的 "defaultText",應該在 SQL 環境定義中使用特殊格式。這些格式包括 'DATE ''2001-12-25''' 和 'DATETIME ''2001-12-25 12:00:00'''。在所有其他環境定義中,使用 date/datetime,而不加上關鍵字和跳出單引號(例如,'2001-12-25')。 提示使用者輸入一個以上的值或成員。只有 "prompt_name" 是必要項目。若沒有指定資料類型,則預設的資料類型為 'string'。若有指定 "defaultText",提示便為選用的。若有指定 "Text",此文字將會顯示在值清單的前面。可將 "QueryItem" 指定為使用 "queryItem" 的提示資訊內容。若有指定 "Trailing_text",此文字將會附加至值清單的後面。資料類型為 'memberuniquename' 時,則會建立多重選取成員提示。最好是提供預設值,作為第三個引數。預設值必須是有效的成員唯一名稱;它也可以是別名,其參照 Report Studio 中所完成的成員唯一名稱。 promptmany ( prompt_name , datatype , defaultText , text , queryItem , trailing_text ) 範例:select . . . where COUNTRY_MULTILINGUAL.COUNTRY in ( # promptmany ( 'CountryName' ) # ) 結果:select . . . where COUNTRY_MULTILINGUAL.COUNTRY_CODE in ( '加拿大' , '荷蘭' , '俄羅斯' ) 範例:select . . . from gosales.gosales.dbo.COUNTRY_MULTILINGUAL COUNTRY_MULTILINGUAL , gosales.gosales.dbo.COUNTRY XX where COUNTRY_MULTILINGUAL.COUNTRY_CODE = XX.COUNTRY_CODE # promptmany ( 'Selected CountryCodes' , 'integer' , ' ' , ' and COUNTRY_MULTILINGUAL.COUNTRY_CODE in ( ' , '' , ' ) ' ) # 結果:select . . . from gosales.gosales.dbo.COUNTRY_MULTILINGUAL COUNTRY_MULTILINGUAL , gosales.gosales.dbo.COUNTRY XX where COUNTRY_MULTILINGUAL.COUNTRY_CODE = XX.COUNTRY_CODE and COUNTRY_MULTILINGUAL.COUNTRY_CODE in ( '加拿大' , '荷蘭' , '俄羅斯' ) 範例:set ( #promptmany ('myProduct', 'memberuniquename', '[Camping Equipment]', '', '[Sales].[Product].[Product].[Product line]')#) 結果:set([Sales].[Product].[Product].[Product line]->[all].[1]; [Sales].[Product].[Product].[Product line]->[all].[2]) 執行對單一直欄的查詢,並在第一列(僅)傳回值。結果尚未格式化,請確認以 sq () 括住呼叫(如果需要)。 queryValue ( value_expression [ , filter_expression ] ) 範例:# sq ( queryValue ( 'TheCalendar.TheWeekdayName' , 'TheCalendar.TheDate = 2018-06-06' ) ) # 結果:'Wednesday' 從參數清單中建構陣列。 array ( string_expression|array_expression { , string_expression|array_expression } ) 範例:# csv ( array ( 'a1' , array ( 'x1' , 'x2' ) , 'a2' ) ) # 結果:'a1' , 'x1' , 'x2' , 'a2' 從陣列的元素建構字串,其中的值是以逗點區隔。可以選擇性地指定分隔字元和引號字串。預設分隔字元是逗號 ( , ),預設引號字元則是單引號 ( ' )。 csv ( array_expression [ , separator_string [ , quote_string ] ] ) 範例:# sq ( csv ( array ( 'a1' , 'a2' ) ) ) # 結果:'a1', 'a2' 從 IBM® Cognos® 配置檔取得項目。force_decode_flag 是選用的,但必須是下列其中一項:'true'、'1'、1、'false'、'0'、0。預設值為 'false'。在例外的狀況下,force_decode_flag 應該設為 true。 當 force_decode_flag 設為 true,然後透過「進階」內容針對項目配置於 IBM® Cognos® Configuration 中時,將會傳回配置項目的純文字值。 對於「進階」內容中未識別的項目,不管加密資訊的出現,會傳回空字串。 「進階」內容中的項目為 qs.getConfigurationEntry.1,並且為以分號區隔的名稱清單,此名稱清單依預設是空白的,同時使用設為 true 的旗標對此函數進行呼叫時,將會傳回空字串。 getConfigurationEntry ( entry_string , force_decode_flag ) 範例:# getConfigurationEntry ( 'serverLocale'  ) # 結果:en 從資源檔中傳回一個項目。 第一個引數是資源檔中找到的資源 ID。選用的第二個引數是無語言環境字尾的資源檔名(例如,若為訊息檔 'mfwa4j_en.properties',則為 'mfwa4j')。預設的資源檔為 'xqejavamsgs'。選用的第三個引數為語言環境,其預設為 'en'。 getResourceString ( resource_id_string [, resource_file_string [ , locale_string ] ] ) 範例:# getResourceString ( 'XQE_BIN_binLow' ) # 結果:XQE-BIN-0001 小於 %1 範例:# getResourceString ( 'MFW_UT_INTERNAL_ERROR' , 'mfw4j' , 'en' ) # 結果:MFW-UT-1002 發生內部問題。請與系統管理者聯絡。 搜尋並傳回與 "pattern_string" 中所指定的型樣相符的陣列元素。 僅支援的 meta 字元是: ^(字頭)、 $(字尾)、 ! (否定 - 僅支援作為第一個字元)。 grep ( pattern_string , array_expression ) 範例:# sq ( csv ( grep ( 's' , array ( 'as', 'an', 'arts' ) ) ) ) # 結果:'as', 'arts' 範例:# sq ( csv ( grep ( '^g' , array ( 'group', 'golf' ) ) ) ) # 結果:'group', 'golf' 範例:# sq ( csv ( grep ( 's$' , array ( 'oranges', 'mangoes' ) ) ) ) # 結果:'oranges', 'mangoes' 範例:# sq ( csv ( grep ( '!o' , array ( 'oranges', 'apples' ) ) ) ) # 結果:'apples' 在找到 'substr' 的 'str' 中尋找偏移。未找到 'substr' 時會傳回值 -1。您也可以提供選用的 'offset' 以從其中開始搜尋。第一個引數 'str' 也可以是 array_expression,在這種情況下,函數會套用於每一個陣列元素,而函數結果是值的陣列。 index ( str , substr [ , offset ] ) # index ( 'The black horse jumped over the black sheep.', 'black' ) # 結果:4 # index ( 'The black horse jumped over the black sheep.', 'black', 10 ) # 結果:32 # index ( 'The black horse jumped over the black sheep.', 'green' ) # 結果:-1 # sq ( join ( ' | ', index ( array ('black' , 'red', 'green' ) , 'e' ) ) ) # 結果:-1 | 1 | 2 使用 "separator_string" 結合陣列元素。 join ( separator_string , array_expression ) 範例:# sq ( join ( ' | | ' , array ( 'as', 'an', 'arts' ) ) ) # 結果:'as | | an | | arts' 計算 string_expression 中的字元數。如果引數是 array_expression,則結果將是值陣列,每一個項目將是每個 array_expression 元素中的字元數。 length ( string_expression | array_expression ) length ( 'abcdef' ) 結果:6 join ( '--', length ( array ( 'abcdef' , 'xyz' ) ) ) 結果:6--3 在找到 'substr' 的 'str' 中尋找最後一個偏移。此函數稱為反向索引,您可以將其視為如同其從字串尾端開始掃描。未找到 'substr' 時會傳回值 -1。您也可以提供選用的 'offset' 以從其中結束搜尋。第一個引數 'str' 可以是 array_expression,在這種情況下,函數會套用於每一個陣列元素,而函數結果是值的陣列。 rindex ( str , substr [ , offset ] ) # rindex ( 'The black horse jumped over the black sheep.', 'black' ) # 結果:32 # rindex ( 'The black horse jumped over the black sheep.', 'black', 10 ) # 結果:4 # rindex ( 'The black horse jumped over the black sheep.', 'green' ) # 結果:-1 # sq ( join ( ' | ', rindex ( array ('black' , 'red', 'green' ) , 'e' ) ) ) # 結果:-1 | 1 | 3 從第一個引數刪掉尾端字元。選用的第二個引數定義要刪掉的字元集。依預設,此函數會刪掉空格(例如,空格、標籤、換行,以及換行)。 rstrip ( string_expression [ , set_of_characters ] ) 範例:# sq( rstrip ( ' abc ' ) ) # 結果:' abc' 範例:# rstrip ( ' 0053.2100 ' , '0 \t\r\n' ) # 結果:0053.21 依字母順序對陣列中的元素進行排序。會保留重複內容。 sort ( array_expression ) 範例:# csv ( sort ( array ( 's3', 'a', 'x' ) ) ) # 結果:'a', 's3', 'x' 將陣列中的字串或字串元素分割為個別的元素。 split ( pattern_string, string_expression|array_expression ) 範例:# sq ( csv ( split ( '::', 'ab=c::de=f::gh=i' ) ) ) # 結果:'ab=c', 'de=f', 'gh=i' 範例:# sq ( csv ( split ( '=' , split ( '::', 'ab=c::de=f::gh=i' ) ) ) ) # 結果:'ab', 'c', 'de', 'f', 'gh', 'i' 從第一個引數刪掉前導字元及尾端字元。選用的第二個引數定義要刪掉的字元集。依預設,此函數會刪掉空格(例如,空格、標籤、換行,以及換行)。 strip ( string_expression [ , set_of_characters ] ) 範例:# sq( strip ( ' abc ' ) ) # 結果:'abc' 範例:# strip ( ' 0053.2100 ' , '0 \t\r\n' ) # 結果:53.21 搜尋字串或陣列的字串元素中的型樣,並將出現的第一個 "pattern_string" 取代為 "replacement_string"。 僅支援的 meta 字元是: ^(字頭)、 $(字尾) substitute ( pattern_string, replacement_string, string_expression|array_expression ) 範例:#sq ( substitute ( '^cn=', '***', 'cn=help' ) )# 結果:'***help' 範例:# csv ( substitute ( '^cn=', '***', array ( 'cn=help' , 'acn=5' ) ) ) # 結果:'***help', 'acn=5' 範例:# csv ( substitute ( 'cn=', '', array ( 'cn=help' , 'acn=5' ) ) ) # 結果:'help', 'a5' 範例:#sq ( substitute ( 'help$', '***', 'cn=help' ) )# 結果:'cn=***' 從在 'start_offset' 開始的 'string_expression' 中擷取一部分。您可以指定要擷取的 'length' 字元數。如果未指定 'length',則會傳回 'string_expression' 的最尾端。第一個引數也可以是 array_expression,在這種情況下,函數會套用於每一個陣列元素,而函數結果是字串的陣列。 substr ( string_expression , start_offset [ , length ] ) substr ( 'The horse is black.', 0, 3 ) 結果: substr ( 'The horse is black.', 4 ) 結果:horse is black。 substr ( 'The horse is black', index ('The horse is black.' , 'green' ) ) 結果:horse is black。 join ( ' | ', substr ( array ('black' , 'red', 'green' ) , 2, 2 ) ) 結果:ac | d | en substr ('over the moon', -2, 4) 導致錯誤:函數 'substr' 的第二個引數必須大於或等於 -1。 傳回以包含時區的時間戳記來表示的 "string_expression1",此時間戳記會修整為 "string_expression2" 中所指定的格式。"string_expression2" 中的格式必須是下列其中一項:'yyyy'、'mm'、'dd'、'yyyy-mm'、'yyyymm'、'yyyy-mm-dd'、'yyyymmdd'、'yyyy-mm-dd hh:mm:ss'、'yyyy-mm-dd hh:mm:ss+hh:mm'、'yyyy-mm-dd hh:mm:ss.ff3'、'yyyy-mm-dd hh:mm:ss.ff3+hh:mm'、'yyyy-mm-ddThh:mm:ss'、'yyyy-mm-ddThh:mm:ss+hh:mm'、'yyyy-mm-ddThh:mm:ss.ff3+hh:mm' 或 'yyyy-mm-ddThh:mm:ss.ff3+hh:mm'。依預設,傳回包含時區的時間戳記的字串表示法的巨集函數會顯示 9 位數字的精準度代表秒的小數部分。格式選項允許將此精準度修整為 3 或 0。 timestampMask ( string_expression1 , string_expression2 ) 範例:# timestampMask ( $current_timestamp , 'yyyy-dd-mm' ) # 結果:2005-11-01 範例:# timestampMask (  '2005-11-01 12:00:00.000-05:00' , 'yyyy-mm-dd hh:mm:ss+hh:mm' ) # 結果:2005-11-01 12:00:00-05:00 範例:# timestampMask (  '2005-11-01 12:00:00.123456789-05:00' , 'yyyy-mm-ddThh:mm:ss+hh:mm.ff3+hh:mm' ) # 結果:2005-11-01T12:00:00.123-05:00 傳回一個字串,此字串代表將 "string_expression" 調整為作業系統的時區後所產生的包含時區的時間戳記。請注意,可以使用巨集函數 timestampMask() 來修整輸出。 toLocal ( string_expression ) 範例:# toLocal ( '2005-11-01 17:00:00.000-00:00' ) # 其中 OS 當地時區是 -05:00 結果:2005-11-01 12:00:00.000000000-05:00 範例:# timestampMask ( toLocal ( '2005-11-01 17:00:00.000-00:00' ) , 'yyyy-mm-dd hh:mm:ss+hh:mm' ) # 其中 OS 當地時區是 -05:00 結果:2005-11-01 12:00:00-05:00 範例:# toLocal ( '2005-11-01 13:30:00.000-03:30' ) # 其中 OS 當地時區是 -05:00 結果:2005-11-01 12:00:00.000000000-05:00 返回字串 "string_expression",其具有使用語言環境規則 "locale_string" 轉換為小寫的全部字元。若沒有指定語言環境,將會使用語言環境 'en'。 tolower ( string_expression [ , locale_string ] ) 範例:# tolower ( 'ABC' ) # 結果:abc 範例:# tolower ( 'ABC' , 'fr' ) # 結果:abc 返回字串 "string_expression",其具有使用定義於 "locale_string" 中的語言環境規則來轉換為大寫的全部字元。如果沒有指定 "locale_string",將會使用語言環境 'en'。 toupper ( string_expression [ , locale_string ] ) 範例:# toupper ( 'abc' ) # 結果:ABC 範例:# toupper ( 'abc' , 'fr' ) # 結果:ABC 傳回一個字串,此字串代表將 "string_expression" 調整為零點參照 UTC 時區(也稱為 GMT 時間)後所產生的包含時區的時間戳記。請注意,可以使用巨集函數 timestampMask() 來修整輸出。 toUTC ( string_expression ) 範例:# toUTC ( '2005-11-01 12:00:00.000-05:00' ) # 結果:2005-11-01 17:00:00.000000000-00:00 範例:# timestampMask( toUTC ( '2005-11-01 12:00:00.000-05:00' ) , 'yyyy-mm-dd hh:mm:ss.ff3+hh:mm' ) # 結果:2005-11-01 17:00:00.000-00:00 範例:# toUTC ( $current_timestamp ) # 結果:2005-11-01 17:00:00.000000000-00:00 從陣列中移除重複項目。會保留元素順序。 unique ( array_expression ) # csv ( unique ( array ( 's3', 'a', 's3', 'x' ) ) ) # 結果:'s3', 'a', 'x' URL 可編碼傳遞的引數。當在指定 XML 連線字串時,此函數很有用。 urlencode ( prompt ( 'userValue' ) ) urlencode ( prompt ( 'some_val' ) ) %27testValue%27 簡單 case 此巨集建構是簡式案例的範本,包括 case、when、then、else、及 end 函數。請注意,只在 DQM 模式中才支援此巨集建構。 CASE <expression> WHEN <literal> THEN <expression> [ELSE <expression>] END Example: #CASE prompt('pDateRange','token') WHEN 'Current Week' THEN '[PR Current Week]' ELSE '[PR Prior Week]' END# 結果:[PR 現行星期]
區塊函數 此清單包含用來存取集成員的函數,通常是在 Analysis Studio 的環境定義中。 傳回在集中找到的前幾個成員,最高達 "numeric_expression_maximum" + "numeric_expression_overflow" 個成員。如果超過 "numeric_expression_maximum" + "numeric_expression_overflow" 個,則只會傳回最大數量的成員。如果成員集中所擁有的成員數只比指定的 numeric_expression_maximum 多幾個,numeric_expression_overflow 便允許包括小的額外成員集。如果集具有的成員數比溢位所允許的還多,則將只會傳回 numeric_expression_maximum 個成員。 _firstFromSet ( set_expression , numeric_expression_maximum , numeric_expression_overflow ) _firstFromSet ( [great_outdoors_company].[Products].[Products].[Product line] , 2 , 8 ) 結果:傳回「產品線」集中的五個成員。前兩個成員在最大值範圍內傳回,後來的三個成員會當成溢位傳回。 露營器材 高爾夫球器材 登山器材 戶外防護器材 個人配件 _firstFromSet ( [great_outdoors_company].[Products].[Products].[Product line] , 2 , 2 ) 結果:露營器材, 高爾夫球器材 當 "set_expression" 的大小大於 "numeric_expression" 時,傳回包含 "member_expression" 的集;亦即,如果 "set_expression" 中的成員數目大於指定的 "numeric_expression",將會產生新的成員。 _remainderSet ( member_expression, set_expression , numeric_expression ) _remainderSet ( member ( aggregate ( currentMeasure within set [great_outdoors_company].[Products].[Products].[Product line] ) , 'Product Aggregate' , 'Product Aggregate' , [great_outdoors_company].[Products].[Products] ) , [great_outdoors_company].[Products].[Products].[Product line] , 1 ) 結果:「產品彙總」的銷售量