我的水晶报告中没有显示某些数据集字段 [英] Some data set field are not showing in my crystal report

查看:59
本文介绍了我的水晶报告中没有显示某些数据集字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,

我是编程新手,我使用c#和水晶报表为Visual Studio中的商店构建应用程序以生成报告。但我有一个问题与报告,我有一个查询,我用来从我的SQL数据库中获取数据并显示在我的水晶报告,但一些数据字段没有显示。但如果我在不使用该组的情况下编写查询,则会显示。以下是查询



  从POS中选择Itemname,SUM(QntSold),SUM(TotalAmnt),其中Date =' + Convert.ToDateTime(date)+  < span class =code-string>'GROUP BY Itemname; 





以上查询只会显示组项目名称,不会显示另外两个表格字段,即QntySoild和TotalAmnt。但是,如果我写这个其他查询它将显示所有表字段但不会对itemname进行分组,下面是显示所有但不是组格式的另一个查询。



  从POS中选择*,其中date =' +转换。 ToDateTime(日期)+  '; 







Plz是一个错误的东西,因为我希望它被分组在一起,所以它不会显示其他字段。

谢谢



我的尝试:



从POS中选择Itemname,SUM(QntSold),SUM(TotalAmnt),其中Date ='+ Convert.ToDateTime(date)+'GROUP BY Itemname;

解决方案

< blockquote>当您应用SUM()等聚合函数时,会丢失列名。所以你需要给它起一个名字,就像非聚合结果列一样。



试试



 选择项目名称,SUM(QntSold) AS  QntSold,SUM(TotalAmnt)  as  TotalAmnt 来自 POS 其中 日期 = ' + Convert.ToDateTime(date)+'  GROUP   BY 项目名称 < span class =code-string>;  


谢谢Mnaught,两个现场工作正常,他们都在我的水晶报告上显示但是我注意到日期没有显示在我作为报告标题的日期字段中,我还能做些什么来使日期显示。提前谢谢


Hello,
Am new to programming, i build an application for a store in visual studio using c# and crystal report for report generation. but i have a problem withe the report, i have a query that i use to fetch data from my sql database and display it on my crystal report but some data field are not showing. but if i write the query without using the group by it will show. below is the query

"select Itemname, SUM(QntSold), SUM(TotalAmnt) from POS  where Date ='" + Convert.ToDateTime(date) + "'GROUP BY Itemname";



with the above query it will only show the group itemnames and will not show the other two table fields which are QntySoild and TotalAmnt. But if i write this other query it will show all the table fields but will not group the itemname, below is the other query that display all but not in group format.

"select * from POS where date ='" + Convert.ToDateTime(date) + "'";




Plz is anything am doing wrong that is not making it to show other fields when it is been grouped because i want it to be grouped together
Thank you

What I have tried:

"select Itemname, SUM(QntSold), SUM(TotalAmnt) from POS where Date ='" + Convert.ToDateTime(date) + "'GROUP BY Itemname";

解决方案

When you apply aggregate functions like SUM() you lose the column name. So you need to give it a name just like the non-aggregated result columns.

try

select Itemname, SUM(QntSold) AS QntSold, SUM(TotalAmnt) as TotalAmnt from POS where Date ='" + Convert.ToDateTime(date) + "'GROUP BY Itemname"; 


Thank you Mnaught, both field works fine now and they are both showing on my crystal report but I noticed the date is not showing in date field which I make as the header of the report, what can I do to also make the date to Show. Thank you in advance


这篇关于我的水晶报告中没有显示某些数据集字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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