如何在水晶报告中使用if语句 [英] how with an if statement in crystal reports

查看:49
本文介绍了如何在水晶报告中使用if语句的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何写一个条件/声明,让我得到下面决赛桌中的结果?我有2个表,有相似的列,但在最终表中,我需要根据代码和EDLType / codetype / DLType显示相应的描述。



can有人请帮助我。



决赛桌:

how do i write a condition/statement that gets me the results seen in final table below? i have 2 tables, that have similar column, but in the final table i need to display the appropriate Description depending on the code and EDLType/codetype/DLType.

can someone help me please.

Final table:

comp    EDLType    EDLCODE    Eployee#    Desc
102      D         1          1000        Portion
102      D         2          1000        salary
102      D         3          1000        A.Tax
102      D         100        1000        Support
102      E         4          1000        T.time
102      E         1          1000        RTime
102      E         2          1000        OT
102      L         201        1000        E.Portion
102      L         200        1000        C.Portion





表1:



table 1:

Comp    ECode    Desc         codetype   
102      1       RTime        E   
102      2       OT           E   
102      3       DT           E   
102      4       T.time       E   
102      5       autopay      E   





表2:



table 2:

comp    DLCode    Desc           DLType   
102      1        Portion        D   
102      2        salary         D   
102      3        A.Tax          D   
102      4        B.Tax          D   
102      5        C.Tax          L   
102      200      C.Portion      L   
102      201      E.Portion      L   
102      100      Support        D   

推荐答案

您可以通过使用左连接(或内连接)将表连接在一起来实现此目的,具体取决于您的数据和需求)。您上面的示例似乎缺少一些信息(例如员工编号来自哪里),但您需要的一般结构如下:



You can achieve this by joining tables together using left join (or inner join, depending on your data and needs). Your sample above appears to be missing some information (such as where the Employee Number is coming from), but the general structure you need is like this:

select FIELD1, FIELD2 from table1
left join table2 on table1.DLCode = table2.EDLCode


我已经完成了左外连接,但是我得到了错误的desc。如果我在我的报告上显示两个desc字段,对于某些edlcodes我得到2个desc。一个来自表1,另一个来自表2.



emp#来自另一个表。我不认为我的问题需要它,对不起。



有没有其他方法可以实现我想要的?例如在if / loop语句中?
i have done the left outer join, but i am getting the wrong desc. if i display both desc fields on my report, for certain edlcodes i am getting 2 desc. one from table 1 and the other from table 2.

the emp # is coming form another table. i didn't think it was needed for my question, sorry about that.

is there any other way a achieve what i want? for example in a if/loop statement?


请看下面,所有与左外连接一起加入。

主表是PREA,

prea.prco到[all_tables] .prco

prea.employee to prel.employee

prea.edlcode to prdl.dlcode

prea .edltype到prdl.dltype

prea.edlcode到prec.earncode



please see below, all joined with left outer join.
primary table is PREA,
prea.prco to [all_tables].prco
prea.employee to prel.employee
prea.edlcode to prdl.dlcode
prea.edltype to prdl.dltype
prea.edlcode to prec.earncode

SELECT [PRCo]
      ,[EarnCode]
      ,[Description]
  FROM [bPREC]


SELECT [PRCo]
      ,[DLCode]
      ,[Description]
      ,[DLType]
  FROM [bPRDL]

SELECT [PRCo]
      ,[Employee]
      ,[EDLType]
      ,[EDLCode]
  FROM [bPREA]

SELECT [PRCo]
      ,[Employee]
      ,[LeaveCode]
  FROM [bPREL]







希望以上帮助




hope the above helps


这篇关于如何在水晶报告中使用if语句的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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