SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Sql query
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

abhijitklg
Starting Member

India
1 Posts

Posted - 09/11/2013 :  05:15:19  Show Profile  Reply with Quote
Sir,
I have two tables as follows,

TABLE A
GROUP STARTACCNO ENDACCNO
A 100 999
B 1000 3000


TABLE B
ACCNO GROUP
230 A
500 A
1000 B
300 A
100 A
2500 B
3000 B

My Requirement is as follows,
SELECT B.*
CASE
IF B.ACCNO BETWEEN A.STARTACCNO AND A.ENDACCNO AND B.GROUP = A.GROUP THEN ‘OK’
ELSE ‘PLEASE CHECK’

Sir please guide how to achieve this.


bandi
Flowing Fount of Yak Knowledge

India
2224 Posts

Posted - 09/11/2013 :  07:23:56  Show Profile  Reply with Quote

SELECT B.*, A.*, CASE WHEN B.ACCNO BETWEEN A.STARTACCNO AND A.ENDACCNO THEN 'OK' ELSE 'Check' END
FROM TABLEA A
LEFT JOIN TABLEB B ON B.[GROUP] = A.[GROUP]


--
Chandu
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.09 seconds. Powered By: Snitz Forums 2000