starts_with()
指定された文字が文字列の先頭にある場合に true を返します。
構文
starts_with(string, prefix)
使用方法
string の先頭が prefix の場合は true、それ以外の場合は false を返します。文字列の比較では、大文字と小文字は区別されません。いずれかのパラメータが null の場合、関数は null を返します。prefix が空の文字列の場合、関数は null を返します。
例
所有者ロールが「Sales」で始まる商談をカウントするとします。starts_with() は、case ステートメントで使用します。
1q = load "DTC_Opportunity";
2
3-- Select rows where the owner roles starts with "Sales"
4q = foreach q generate count() as 'count', (case
5 when starts_with('Owner_Role', "Sales") then 'Owner_Role'
6end) as 'Owner_Role';
7
8q = group q by 'Owner_Role';
9q = foreach q generate count() as 'count', 'Owner_Role' as 'Owner_Role';結果のグラフには、所有者ロールが「Sales」で始まる商談の数が所有者ロール別に示されています。
