473,394 Members | 1,702 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

case in joins

Hi All,

I am trying following case statement in where clause but it shows
line 2:incorrect syntax near"=" state:42000.
Any one please helpme i am trying this from past 2 weeks
Expand|Select|Wrap|Line Numbers
  1. CASE 
  2. WHEN 
  3. (Surveillance.dbo.Deal_Hdr.Sector = 'MBS'  OR  (Surveillance.dbo.Deal_Hdr.sector='ABS'  AND  Surveillance.dbo.Deal_Hdr.sic_Secno='HOMEEQUITY'))
  4. THEN 
  5. (dbo.Deal_Underwriting_Info.COLLATERAL_TYPE_ID = dbo.MBS_Collateral_Types.COLLATERAL_TYPE_ID)
  6. WHEN  
  7. Surveillance.Deal_Hdr.sector='ABS' 
  8. THEN  
  9. dbo.Deal_Underwriting_Info.ABS_COLLATERAL_TYPE_ID = dbo.ABS_Collateral_Types.COLLATERAL_TYPE_ID
  10. ELSE
  11. NULL
  12. END
  13.  
Thanks

Praveen.S
Feb 5 '08 #1
2 1158
amitpatel66
2,367 Expert 2GB
Hi All,

I am trying following case statement in where clause but it shows
line 2:incorrect syntax near"=" state:42000.
Any one please helpme i am trying this from past 2 weeks

CASE
WHEN
(Surveillance.dbo.Deal_Hdr.Sector = 'MBS' OR (Surveillance.dbo.Deal_Hdr.sector='ABS' AND Surveillance.dbo.Deal_Hdr.sic_Secno='HOMEEQUITY'))
THEN
(dbo.Deal_Underwriting_Info.COLLATERAL_TYPE_ID = dbo.MBS_Collateral_Types.COLLATERAL_TYPE_ID)
WHEN
Surveillance.Deal_Hdr.sector='ABS'
THEN
dbo.Deal_Underwriting_Info.ABS_COLLATERAL_TYPE_ID = dbo.ABS_Collateral_Types.COLLATERAL_TYPE_ID
ELSE
NULL
END


Thanks

Praveen.S
Try this:

Expand|Select|Wrap|Line Numbers
  1.  
  2. CASE 
  3. WHEN 
  4. (Surveillance.dbo.Deal_Hdr.Sector = 'MBS'  OR  (Surveillance.dbo.Deal_Hdr.sector='ABS'  AND  Surveillance.dbo.Deal_Hdr.sic_Secno='HOMEEQUITY'))
  5. THEN 
  6. (dbo.Deal_Underwriting_Info.COLLATERAL_TYPE_ID = dbo.MBS_Collateral_Types.COLLATERAL_TYPE_ID)
  7. CASE WHEN  
  8. Surveillance.Deal_Hdr.sector='ABS' 
  9. THEN  
  10. dbo.Deal_Underwriting_Info.ABS_COLLATERAL_TYPE_ID = dbo.ABS_Collateral_Types.COLLATERAL_TYPE_ID
  11. ELSE
  12. NULL
  13. END
  14.  
  15.  
Feb 5 '08 #2
HI Amit,

Thanks for your reply.
I had tried that but no use.
It is showing same error.

I had one doubt can i use above query in where clause


Thanks
Feb 6 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: jgalzic | last post by:
Hi, I'm having trouble doing joins correctly on two tables. I've read up a lot about the different types of joins and tried lots of variations on inner, outer, and left joins with no avail....
3
by: Prem | last post by:
Hi, I am having many problems with inner join. my first problem is : 1) I want to know the precedance while evaluating query with multiple joins. eg. select Employees.FirstName,...
4
by: Sri | last post by:
I am writing a download process in which i have a condition where i need to join four tables. Each table have lot of data say around 300000 recs. my question is when i am doing the joins on...
2
by: raulgz | last post by:
Hi I work ith sql server 2000 and i need know the diferent of joins in format not ansi ( with * ) and joins in format ansi ( with 'outher join on' ). Two format work equal ???
4
by: jbm05 | last post by:
Hi, I'm curious about the computational complexity of a query I have. The query contains multiple nested self left joins, starting with a simple select, then doing a self left join with the...
4
by: michaelnewport | last post by:
Greetings, I like to write my inner joins as below, but someone at work tells me its not as 'performant' as using the 'inner join' statement. Is this true ? Is there a better way to write it...
7
by: Steve | last post by:
I have a SQL query I'm invoking via VB6 & ADO 2.8, that requires three "Left Outer Joins" in order to return every transaction for a specific set of criteria. Using three "Left Outer Joins"...
2
by: narendra vuradi | last post by:
Hi I have a requirement where in i haev to convert the SQL from Oracle to the one which will run on the SQL server. in the Oracle Query i am doing multiple joins, between some 13 tables. and...
9
by: shapper | last post by:
Hello, I am used to SQL but I am starting to use LINQ. How can I create Left, Right and Inner joins in LINQ? How to distinguish the different joins? Here is a great SQL example:...
36
by: TC | last post by:
I've used Access for many years. Several times, I've encountered a bug which I refer to as the "Vanishing Joins" bug. When it happens, joins vanish randomly from queries. More specifically, all...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.