Solved

# Crystal Report

Posted on 2014-07-26
497 Views
I have table that 5 columns
ID   Name    Account1    Account2 Account3 Account4
19   John       212                444            325           0
22   Chris      333                212            213         234
15   Steve     212                458             235         213
12    Jim        324                876            123          212.

I would like to retrieve all the data that have "212" Account#. It could be in any column.

What SQL Statement I can use to get this data?
0
Question by:snhandle
[X]
###### Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

• Help others & share knowledge
• Earn cash & points

LVL 49

Accepted Solution

PortletPaul earned 250 total points
ID: 40222204
If an account number is a string then use '212' if it is an integer just use 212
``````SELECT
ID
, Name
, Account1
, Account2
, Account3
, Account4
FROM ThatTable
WHERE (  Account1 = '212'
OR Account2 = '212'
OR Account3 = '212'
OR Account4 = '212'
)
``````
0

LVL 101

Assisted Solution

mlmcc earned 250 total points
ID: 40224103
The above comment will work if you are creating the view in the database or using a COMMAND as the data source.

If you are doing this in Crystal you only need to have the WHERE part in the SELECT EXPERT.

{YourTable.Account1} = "212"
OR
{YourTable.Account2} = "212"
OR
{YourTable.Account3} = "212"
OR
{YourTable.Account4} = "212"

If the field is numeric remove the " " around the 212

mlmcc
0

LVL 35

Expert Comment

ID: 40226615
Just for the heck of it, this is a slightly different way to do the same thing:

"212" in [ {table.Account1}, {table.Account2}, {table.Account3}, {table.Account4} ]

It's not really any better.  Just different.  Maybe a little "simpler".

James
0

## Featured Post

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Crystal Reports: 5 Tests for Top Performance It is complete, your masterpiece report.  Not only does it meet your customer’s expectations, it blows them out the water, all they want is beautifully summarised and displayed in a myriad of ways. …
I hate sub reports and always consider them the last resort in any reporting solution.  The negative effect on performance and maintainability is just not worth the easy ride they give the report writer.  Nine times out of ten reporting requirements…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
###### Suggested Courses
Course of the Month4 days, 7 hours left to enroll