Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2020 : Report Design
Message Icon Topic: SQL formula %test Post Reply Post New Topic
Author Message
elly00
Newbie
Newbie


Joined: 24 May 2011
Online Status: Offline
Posts: 10
Quote elly00 Replybullet Topic: SQL formula %test
    Posted: 23 Jul 2021 at 2:59am
Hi

I'm using crystal sql formula syntax I need to set something like that..

if field1='' os field1 is null then
(
SELECT TOP 1 aaa
FROM my table

else
(
select TOP1 bbb
FROM my table 2
)

What is the correct syntax to use?


Thanks

IP IP Logged
kevlray
Admin Group
Admin Group
Avatar

Joined: 29 Oct 2009
Online Status: Offline
Posts: 1587
Quote kevlray Replybullet Posted: 26 Jul 2021 at 3:45am
I do not believe you can do that in a formula, but I think you would have to do in in a SQL Expression Field or a Command.  But the MS-SQL syntax would look something like this (I am assuming that field 1 is from another table).

SELECT CASE WHEN field1 IS NULL THEN (SELECT TOP 1 aaa FROM myTable ELSE
  (SELECT TOP 1 bbb from myTable2) END

FROM ANOTHERTABLE

FROM
IP IP Logged
Post Reply Post New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum



This page was generated in 0.016 seconds.