在Crystal Reports 12中显示没有数据的组 [英] Display group with no data in Crystal Reports 12

查看:254
本文介绍了在Crystal Reports 12中显示没有数据的组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想根据年龄分组资料。我使用以下数据库选择:

I am trying to group my data based on age. I use the following database select:

select * from (
select 0 range_start, 11 range_end, '0-10 days' date_description from dual union
select 11, 21, '11-20 days' from dual union  
select 21, 31, '21-30 days' from dual union  
select 31, 99999, '31+ days' from dual) date_helper
left outer join table
on table.date <= date_helper.range_start*-1 + sysdate 
and table.date > date_helper.range_end*-1 + sysdate 

然后我根据date_description列创建一个组。我试图让它显示所有组,即使没有记录,那个组内。
如果没有记录,我希望它的值为0,并仍然打印该组。

I then make a group based on the date_description column. I am trying to make it display all groups, even when there are no records, that fall within that group. If there are no records, I want it to have a value of 0, and still print the group.

谢谢!

推荐答案

扩展对PowerUser的回答的评论,如果你使用一个版本的Crystal允许你输入你自己的SQL(而不必使用Crystal的数据库专家),您可以设置一个作为辅助表的子查询 - 例如:

Expanding on a comment on PowerUser's answer, if you're using a version of Crystal that allows you to enter your own SQL (instead of having to use Crystal's Database Expert), you can set up a subquery that acts as a helper table - something like:

select * from (
select 0 range_start, 11 range_end, '0-10 days' date_description from dual union
select 11, 21, '11-20 days' from dual union  
select 21, 31, '21-30 days' from dual union  
select 31, 99999, '31+ days' from dual) date_helper
left outer join 
(select sysdate-5 mydate from dual union all 
 select sysdate - 25 from dual) mytable
on mytable.mydate <= date_helper.range_start*-1 + sysdate 
and mytable.mydate > date_helper.range_end*-1 + sysdate 

(Oracle语法 - 查询的精确语法会有所不同)

(Oracle syntax - the precise syntax of the query will vary depending on which dialect of SQL you are using.)

编辑:从SQLServer更改为Oracle语法。

Changed from SQLServer to Oracle syntax.

FURTHER编辑:添加了一些简单的示例数据。

FURTHER Added some simple sample data.

这篇关于在Crystal Reports 12中显示没有数据的组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆