下拉框能展示数据但无法进行模糊查询为什么

卡来源字段是card_source,sql如下

image.png

image.png

image.png

image.png

为什么下拉框只能展示数据却不能进行正常的筛选模糊查询

FineReport fanruan大头兵 发布于 2025-2-15 14:08
1min目标场景问卷 立即参与
回答问题
悬赏:3 F币 + 添加悬赏
提示:增加悬赏、完善问题、追问等操作,可使您的问题被置顶,并向所有关注者发送通知
共2回答
最佳回答
0
CD20160914Lv8专家互助
发布于2025-2-15 14:49(编辑于 2025-2-15 14:52)

ds1数据集,这个用来单元格展示数据的

select 

t.*

from (

SELECT

sd.email,

consume_phone phone, 

case hg.group_card_kind when '1' then '赠洗卡' else '现金卡' end as card_type,

CASE WHEN hg.group_card_type IN ('X', 'Y', 'V', 'T') THEN '门市充值'

ELSE '团单'END as card_source,

hg.group_name as group_name,

'消费' operatype,

COUNT(hs.consume_card_kind ) AS times,

IFNULL(sum(IF(hs.consume_status='+',(hs.consume_amount),-(hs.consume_amount))),0) money,

sum(hs.consume_gift_amount) as gift_money,

(IFNULL(sum(IF(hs.consume_status='+',(hs.consume_amount),-(hs.consume_amount))),0)-sum(hs.consume_gift_amount)) as last_money

FROM

qianxun_wash_consume hs

LEFT JOIN qianxun_wash_groupcard hg ON (hs.consume_phone = hg.group_phone and hs.consume_card_kind=hg.group_card_kind)

LEFT JOIN sys_dept sd on sd.dept_id=hg.create_dept

WHERE

consume_subtract_card != '0' 

and hs.consume_card_type IS NOT NULL

and hs.create_unit='101'

and hs.consume_card_type <> ' '

AND hs.consume_type IN

( '200', '220' )

${if(len(startdate)>0," and DATE_FORMAT(hs.create_time, '%Y-%m-%d') >='"+startdate+"'","")}

${if(len(enddate)>0," and DATE_FORMAT(hs.create_time, '%Y-%m-%d') ='"+times+"'","")}

) t

where 1=1

${if(len(card_source)=0,"","and t.card_source='"+card_source+"'")}

ORDER BY t.times DESC

image.png

ds2数据集2  或者自定义数据字典用来筛选card_source

只返回    门市充值  与  团单 两个值就行了!!!

image.png

image.png

  • fanruan大头兵 fanruan大头兵(提问者) 用来自定义数据字典的数据集,我是这样写的还是不行select * from(

    select DISTINCT case hg.group_card_type when (hg.group_card_type IN ( 'X', 'Y','V' ,'T') ) then '门市充值' else '团单' end as card_source from qianxun_wash_groupcard hg where hg.create_unit='101'

    ) hg

    where 1=1

    ${if(len(card_source)>0," and hg.card_source ='"+card_source+"'","")}
    2025-02-15 15:05 
  • CD20160914 CD20160914 回复 fanruan大头兵(提问者) 你这个只是条件 ,不用写了,直接按我说的配置两个固定值就行了!!!你肯定还没有到下拉框的意思!!
    2025-02-15 15:17 
  • CD20160914 CD20160914 回复 fanruan大头兵(提问者) 这个语句不要加参数。就直接配置ds2为两个固定值,或者直接按我截图说的只配置下拉框的数据字典就行了,同时ds1复制我写的就可以了!!!
    2025-02-15 15:18 
  • fanruan大头兵 fanruan大头兵(提问者) 回复 CD20160914 直接配置数据字典也是不能筛选,只有下拉框展示
    2025-02-15 15:24 
  • CD20160914 CD20160914 回复 fanruan大头兵(提问者) 你要不加我,直接远程吧。
    2025-02-15 15:27 
最佳回答
0
用户k6280494Lv6资深互助
发布于2025-2-15 14:10(编辑于 2025-2-15 14:13)

下拉框/下拉复选框/下拉树的模糊搜索

select * from(

select DISTINCT case hg.group_card_type when (hg.group_card_type IN ( 'X', 'Y','V' ,'T') ) then '门市充值' else '团单' end as card_source from qianxun_wash_groupcard hg where hg.create_unit='101' 

) hg

where 1=1

${if(len(card_source)>0," and hg.card_source ='"+card_source+"'","")}

  • fanruan大头兵 fanruan大头兵(提问者) SELECT
    sd.email,
    consume_phone phone, case hg.group_card_kind when '1' then '赠洗卡' else '现金卡' end as card_type,
    CASE
    WHEN hg.group_card_type IN ('X', 'Y', 'V', 'T') THEN '门市充值'
    ELSE '团单'
    END as card_source,
    hg.group_name group_name,
    '消费' operatype,
    COUNT( hs.consume_card_kind ) AS times,
    IFNULL(sum(IF(hs.consume_status='+',(hs.consume_amount),-(hs.consume_amount))),0) money,
    sum(hs.consume_gift_amount) as gift_money,
    (IFNULL(sum(IF(hs.consume_status='+',(hs.consume_amount),-(hs.consume_amount))),0)-sum(hs.consume_gift_amount)) as last_money
    FROM
    qianxun_wash_consume hs
    LEFT JOIN qianxun_wash_groupcard hg ON (hs.consume_phone = hg.group_phone and hs.consume_card_kind=hg.group_card_kind)
    LEFT JOIN sys_dept sd on sd.dept_id=hg.create_dept
    WHERE
    consume_subtract_card != '0' and hs.consume_card_type IS NOT NULL


    and hs.create_unit='101'
    -- AND CAST(
    -- consume_subtract_card AS DECIMAL ( 10, 2 ))> 0
    and hs.consume_card_type <> ' '
    AND hs.consume_type IN
    ( '200', '220' )
    ${if(startdate!=''," and DATE_FORMAT(hs.create_time, '%Y-%m-%d') >='"+startdate+"'","")}
    ${if(enddate!=''," and DATE_FORMAT(hs.create_time, '%Y-%m-%d') ='"+times+"'","")}
    ORDER BY
    times DESC这是我的sql只能展示下拉框内容,不能搜索为什么
    2025-02-15 14:21 
  • 用户k6280494 用户k6280494 回复 fanruan大头兵(提问者) 你下拉框内容得单独一个数据集,不能跟报表内容共用?
    2025-02-15 14:27 
  • fanruan大头兵 fanruan大头兵(提问者) 回复 用户k6280494 好,我试试
    2025-02-15 14:31 
  • 用户k6280494 用户k6280494 回复 fanruan大头兵(提问者) 你要筛选CASE
    WHEN hg.group_card_type IN ('X', 'Y', 'V', 'T') THEN '门市充值'
    ELSE '团单'
    END as card_source,这个字段外面就要在套一个查询语句
    select * from(

    select DISTINCT case hg.group_card_type when (hg.group_card_type IN ( 'X', 'Y','V' ,'T') ) then '门市充值' else '团单' end as card_source from qianxun_wash_groupcard hg where hg.create_unit='101'

    ) hg

    where 1=1

    ${if(len(card_source)>0," and hg.card_source ='"+card_source+"'","")}
    2025-02-15 14:33 
  • 3关注人数
  • 68浏览人数
  • 最后回答于:2025-2-15 14:52
    请选择关闭问题的原因
    确定 取消
    返回顶部