5
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

redashのパラメータで全選択を可能にする

Last updated at Posted at 2020-07-16

redashでフィルターを作成する際にパラメータを利用しますが、フィルターを利用したい場合と利用したくない場合があり、同一クエリーでフィルターを無効にする対応が必要なりました。
そこで下記のような対応をとりました。

SELECT
 *
FROM
 data_table
WHERE
 p_id = 
  CASE WHEN '{{p_id}}' = 'ALL' THEN p_id
       ELSE '{{p_id}}'
       END

パラメータp_idALLを指定した場合は実質フィルターなし(全選択)の状態になります。
p_idの値にALLが存在しない場合に有効な方法となります。

5
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?