Solved

Excluding data from one table field looking up that value from another

Posted on 2016-08-20
6
57 Views
Last Modified: 2016-08-23
Using Crystal Reports IX with SQL Server 2014

 I need to exclude a value based on the value stored in a table field where I lookup the value in another table.  Since this report would be run by multiple agencies and they use their own user assigned value for a "House Watch" I need to find that value from the param3 field in the table ListUCR.


Table and Field I will be excluding data on:    
Table Name: CaseMaster
Table Field: UCRCodeAll   (Varchar)

7725,7741
7725
7314,7725
7314,7741,7725

Table and Fields I am looking up to obtain the value in  the Code field based on a string value in a param3 field.

Table Name: ListUCR
Table Fields: Code        (Char)
Table Field Param3      (Varchar)

Example Department 1

Code            Description                     Param3
7225            HOUSE WATCH               HOUSE WATCH     (Query would use 7225)

Example Department 2

Code            Description                     Param3
7845           HOUSE WATCH               HOUSE WATCH     (Query would use 7845)


I can get it to work if I hardcode a particular value into the query:
not ({CaseMaster.UCRCodeAll} like "*7225*")

But when I try the below listed query it fails to return any records.
{CaseMaster.UCRCodeAll} <> {ListUCR.Code} and ({ListUCR.Param3} Like 'HOUSE WATCH')


Mike
0
Comment
Question by:MikeM670
[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
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 100

Expert Comment

by:mlmcc
ID: 41763993
What is the full query? or at least the full FROM and WHERE clauses?

mlmcc
0
 

Author Comment

by:MikeM670
ID: 41764003
{ClosedCallControl.EnrouteBadge} like ["*" + {?Officer}] and
{ClosedCallControl.InitiationTime} >= {?Start Date} and
{ClosedCallControl.InitiationTime} <= {?End Date} and
{ClosedCallControl.Agency} = {?Agency} and
{CaseMaster.UCRCodeAll} <> {ListUCR.Code} and ({ListUCR.Param3} Like 'HOUSE WATCH')
//not ({CaseMaster.UCRCodeAll} like "*7225*")    (This works)
//{CaseMaster.UCRCode1} like {ListUCR.Code} where ({ListUCR.Param3} Like 'HOUSE WATCH')  (This did not)
0
 
LVL 100

Expert Comment

by:mlmcc
ID: 41764617
<> is not the same as NOT LIKE

Should this
{CaseMaster.UCRCodeAll} <> {ListUCR.Code} and ({ListUCR.Param3} Like 'HOUSE WATCH')

be
({CaseMaster.UCRCodeAll} <> "*" & {ListUCR.Code} & "*") and ({ListUCR.Param3} Like 'HOUSE WATCH')

mlmcc
0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

Author Comment

by:MikeM670
ID: 41766295
mlcc,

Thanks for getting back to me.  

I tried the corrected query you provided and it only returns House Watches.  Which is funny because that is what I wish to exclude from the query and return all other UCRCodes.

If I specifically hardcode a UCR Code value into the query it works fine but when I try to check the ListUCR Table for the Param3 value of "House Watch" it returns only house watches.


Mike
0
 
LVL 100

Accepted Solution

by:
mlmcc earned 500 total points
ID: 41766920
If you don't want "house watch" then use NOT

({CaseMaster.UCRCodeAll} <> "*" & {ListUCR.Code} & "*") and (NOT(({ListUCR.Param3} Like 'HOUSE WATCH')))

mlmcc
0
 

Author Closing Comment

by:MikeM670
ID: 41767435
That did it!  I had tried using not before but not against the Param3 value specifically.  

Thank you very much for the assistance!
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Mask on Parameter CR2008 28 71
Crystal Reports total formula with groups? 4 64
Cyrstal Reports formula to check IsNull 8 43
A string is required here error 20 26
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…
Hello everyone, Hope you find this as helpful as we did. We have on the company I work for an application built in Delphi V with Crystal Reports 8. We all know that Crystal & Delphi can be temperamental sometimes and the worst thing is, nearly…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question