?
Solved

syntax error - in know these records are there

Posted on 2013-02-01
7
Medium Priority
?
238 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 66

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 66

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
Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

 

Author Comment

by:al4629740
ID: 38844727
still nothing.

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

Accepted Solution

by:
Jim Horn earned 1200 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 800 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

NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

Question has a verified solution.

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

A Stored Procedure in Microsoft SQL Server is a powerful feature that it can be used to execute the Data Manipulation Language (DML) or Data Definition Language (DDL). Depending on business requirements, a single Stored Procedure can return differe…
An alternative to the "For XML" way of pivoting and concatenating result sets into strings, and an easy introduction to "common table expressions" (CTEs). Being someone who is always looking for alternatives to "work your data", I came across this …
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Viewers will learn how the fundamental information of how to create a table.
Suggested Courses

807 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