我如何使用多个表从最大到最小订购日期? [英] How I Order Date From Max To Min With Multiple Table?

查看:62
本文介绍了我如何使用多个表从最大到最小订购日期?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Union在一个水晶报表中使用dataSet中的一个表选择多个表,我如何显示从最大日期到最小日期的数据

解决方案

当你结合使用时使用UNION ORDER BY部分的结果集必须在最后一个查询上,它将应用于所有组合记录集...

如果必须对每个查询应用不同的ORDER BY(如如果你有TOP(n),所以ORDER BY会产生所有差异),你必须把这样的查询括起来:

  SELECT  *  FROM  SELECT  fld1,fld1  FROM  tbl1  ORDER   BY  fld1))
UNION
SELECT * FROM SELECT fld1,fld1 FROM tbl2 ORDER BY fld1))


  SELECT  * 
FROM

SELECT *,sortby FROM tblA
UNION ALL
SELECT *,sortby FROM tblB
)tbl
ORDER BY sortby DESC


试试这个。 ..

 CrystalReport1.SelectionFormula =   {Exp。 ETD}日期(&格式(fromDateVariableHere,  yyyy,mm,dd)&  )To Date(& Format(toDateVariableHere,   yyyy,mm,dd))   


I used Union to select multiple table in one crystal report using one table in dataSet, how i display data from max date to min date

解决方案

When you combine result sets using UNION the ORDER BY part must be on the last query and it will apply to all the combined record sets...
If you have to apply different ORDER BY to each and every query (like when you have TOP(n) in them so ORDER BY makes all the differences), you have to enclose the queries like this:

SELECT * FROM (SELECT fld1, fld1 FROM tbl1 ORDER BY fld1))
UNION  
SELECT * FROM (SELECT fld1, fld1 FROM tbl2 ORDER BY fld1))


SELECT  * 
FROM 
        (
            SELECT *, sortby FROM tblA
            UNION ALL 
            SELECT *, sortby FROM tblB
        ) tbl
ORDER   BY sortby DESC


Try this...

CrystalReport1.SelectionFormula = "{Exp.ETD} In Date(" & Format(fromDateVariableHere, "yyyy,mm,dd") & ") To Date(" & Format(toDateVariableHere, "yyyy,mm,dd"))"


这篇关于我如何使用多个表从最大到最小订购日期?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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