Solved

syntax error - in know these records are there

Posted on 2013-02-01
7
231 Views
Last Modified: 2013-02-01
I know data values exist for this string below.  Am I doing something wrong in the syntax

select * from tblJJDP where Fiscal = 2012 and not IVPA = 'I'
0
Comment
Question by:al4629740
7 Comments
 
LVL 65

Expert Comment

by:Jim Horn
ID: 38844648
Possibly, but without access to your data source it's hard to tell.

Knee-jerk reactions...

>Fiscal = 2012
this works if Fiscal is some kind of Numeric.  If it's a char then you'll need Fiscal = '2012'

>and not IVPA = 'I'
and IVPA <> 'I' would be a little cleaner
verify that you want AND instead of OR
Verify that there is capital I, and not also lowercase i records that you want in your results
0
 
LVL 65

Expert Comment

by:Jim Horn
ID: 38844653
>Fiscal = 2012
Also if Fiscal is a date then Year(Fiscal) = 2012
0
 
LVL 3

Expert Comment

by:Nalinkumarbalaji
ID: 38844694
Try this one

select * from tblJJDP where Fiscal ='2012' and IVPA <> 'I'

Go with jimhorn comment
0
NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

 

Author Comment

by:al4629740
ID: 38844727
still nothing.

I do notice that many values in IVPA have either an 'I' or NULL
0
 
LVL 65

Accepted Solution

by:
Jim Horn earned 300 total points
ID: 38844747
>many values in IVPA have either an 'I' or NULL
You'll have to handle the NULL values then, something like using COALESCE, which returns the first non-null value between the parentheses:

select *
from tblJJDP
where Fiscal = 2012 and COALESCE(IVPA, 'foo') <>  'I'
0
 
LVL 32

Assisted Solution

by:awking00
awking00 earned 200 total points
ID: 38844793
Another method -
select * from tblJJdp where Fiscal = 2012
except
select * from tblJJdp where IVPA = 'I'
0
 

Author Comment

by:al4629740
ID: 38844816
Thats crazy I never knew that.
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

947 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now