您好我正在使用crystal并希望添加一个名为Group 1的公式字段,并希望使用这样的SQL查询:
CASE '{?Group 1}'
WHEN 'Location' THEN (CASE WHEN COALESCE(TABLE_NAME_1.COLUMN_NAME_1, TABLE_NAME_1.COLUMN_NAME_2) IS NULL THEN '*Unspecified Location'
WHEN TABLE_NAME_2.COLUMN_NAME_1 IS NULL THEN CONCAT('*Unknown Location', CONCAT(' [',CONCAT(COALESCE(TABLE_NAME_1.COLUMN_NAME_1, TABLE_NAME_1.COLUMN_NAME_2),']')))
WHEN TABLE_NAME_2.COLUMN_NAME_2 IS NULL THEN CONCAT('*Unnamed Location', CONCAT(' [',CONCAT(TABLE_NAME_2.COLUMN_NAME_1,']')))
ELSE TABLE_NAME_2.COLUMN_NAME_2 END)
ELSE NULL END GROUP_1
不完全确定这是如何转化为水晶的。任何帮助都会很棒。 谢谢
好的,我重新设计了公式并提出了:
IF {?Group1} = "Location" THEN
IF ISNULL({TABLE_NAME_1.COLUMN_NAME_1}) THEN "*Unspecified Location" ELSE
IF ISNULL({TABLE_NAME_1.COLUMN_NAME_2}) THEN "*Unspecified Location" ELSE
IF ISNULL({TABLE_NAME_2.COLUMN_NAME_1}) THEN "*Unknown Location" ELSE
IF ISNULL({TABLE_NAME_2.COLUMN_NAME_2}) THEN "*Unnamed Location"
ELSE {TABLE_NAME_2.COLUMN_NAME_2}
我认为这可能有效。你同意还是有更好的方法?
答案 0 :(得分:0)
您的转化几乎正确,需要进行以下检查。
IF {?Group1} = "Location" THEN
(
IF (ISNULL({TABLE_NAME_1.COLUMN_NAME_1}) or ISNULL({TABLE_NAME_1.COLUMN_NAME_2}))
THEN "*Unspecified Location"
ELSE IF ISNULL({TABLE_NAME_2.COLUMN_NAME_1})
THEN "*Unknown Location " &IIF((ISNULL({TABLE_NAME_1.COLUMN_NAME_1}) or ISNULL({TABLE_NAME_1.COLUMN_NAME_2})),{TABLE_NAME_1.COLUMN_NAME_1},{TABLE_NAME_1.COLUMN_NAME_2})
ELSE IF ISNULL({TABLE_NAME_2.COLUMN_NAME_2})
THEN "*Unnamed Location " & {TABLE_NAME_2.COLUMN_NAME_1}
)
ELSE {TABLE_NAME_2.COLUMN_NAME_2}