反馈已提交

网络繁忙

You are viewing 5.1 help doc. More details are displayed in the latest help doc.

Writing example of SQL dataset parameter

  • Recent Updates: April 25, 2022
  • 1. Overview

    This article provides an example of SQL writing for real-time data using SQL dataset parameters.

    Note: Different databases have different writing methods and this article only provides reference examples.

    2. Date parameters

    Date type
    SQL example
    Recommended parameter types
    Yearselect * from new_salesdetail where year(sale date)='${year}'text
    Year Monthselect * from new_salesdetail where year(sale date)='$(year)' and month(sale date)='$(month)'text
    Dateselect * from new_salesdetail where sale date in ('${date}')date
    Date intervalselect * from new_salesdetail where sales date between'${start date}' and'${end date}'date
    Year Month interval

    select * from DEMO_CONTRACT where registration time>= PARSEDATETIME('${start year}'||'-'||0||'${start month}'||'-'||'01','yyyy-MM -dd') and registration time<PARSEDATETIME('${as of year}'||'-'||0||'${as of month}'+1||'-'||'01','yyyy- MM-dd')

    or:

    SELECT * FROM Internet_Access Statistics Table WHERE 1=1 <parameter> and TO_CHAR("Statistic Date",'yyyymm') >=concat('${start year}',case when cast('${start month}' as tinyint)>9 then'${start month}' else concat('0','${start month}') end) and TO_CHAR("statistic date",'yyyymm') <=concat('${as of Year}',case when cast('${up to month}' as tinyint)>9 then'${up to month}' else concat('0','${up to month}') end )</parameter>

    text
    Year Quarterselect * from DEMO_CONTRACT where year(registration time) ='${year}' and (month(registration time)+2)/3 ='${quarter}' text

    3. Text parameters

    Text type
    SQL exampleRecommended parameter types
    The parameter can only take one valueselect * from demo_contract where contract type='${text parameter}'text
    Parameters can take multiple valuesselect * from demo_contract where contract type in ('${text parameter}')text
    When the parameter is empty, display all; when the parameter has a value, display the parameter value

    select * from new_dian where 1=1 ${if(len(Owned region 2) == 0,"","and Owned region in ('" + Owned region 2 + "')")}

    Or: select * from new_dian where 1=1 <parameter> and the area to which it belongs in ('${the area to which it belongs)')</parameter>

    Note: where 1=1 means that the condition is always true, to prevent the occurrence of where there will be an error when there is no subsequent parameter condition.

    text

     


    Attachment List


    Theme: Build Charts and Analyze data
    Already the First
    Already the Last
    • Helpful
    • Not helpful
    • Only read

    售前咨询电话

    400-811-8890转1

    在线技术支持

    在线QQ:800049425

    热线电话:400-811-8890转2

    总裁办24H投诉

    热线电话:173-1278-1526

    文 档反 馈

    鼠标选中内容,快速反馈问题

    鼠标选中存在疑惑的内容,即可快速反馈问题,我们将会跟进处理。

    不再提示

    10s后关闭