Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 how to compare value of two varchar2 fields ?

Author  Topic 

moorthyvisu
Starting Member

7 Posts

Posted - 2007-11-05 : 15:30:37
Hi,

I have to write a SQl query which statisfy the below scenario:

Table name : ClientCode.
Fields are : startcode varchar2(20) & endcode varchar2(20);

The entering values for these two fields should not overlap.

For Ex:

#1. startcode = 50 & endcode = 110
- this is allowed, it means 50 to 100
#2. startcode = 130 & endcode = 180
- this is allowed, it means 130 to 180
#3. startcode = 90 & endcode = 100
- this is not allow, since the values are overlapped. the range 90 - 100 is already present in #1.

So I have to frame a query for this conditions.

I would highly appreciate if any one can post the query to resolve this issue.

Thnx in advance.

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-11-05 : 15:34:30
Why are StartCode and EndCode stored as VARCHARS?



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

moorthyvisu
Starting Member

7 Posts

Posted - 2007-11-05 : 15:37:46
quote:
Originally posted by Peso

Why are StartCode and EndCode stored as VARCHARS?



E 12°55'05.25"
N 56°04'39.16"




the field may have alphanumeric tooo.
My apology for not specifying that in the query.

The field may have alphanumeric character tooo. In that case also I have to compare the values.
Go to Top of Page

dinakar
Master Smack Fu Yak Hacker

2507 Posts

Posted - 2007-11-05 : 16:26:35
Is there any PK on the table like an Identity column?

Dinakar Nethi
************************
Life is short. Enjoy it.
************************
http://weblogs.sqlteam.com/dinakar/
Go to Top of Page

moorthyvisu
Starting Member

7 Posts

Posted - 2007-11-05 : 16:53:23
yes there is a PK on the table.
Go to Top of Page

dinakar
Master Smack Fu Yak Hacker

2507 Posts

Posted - 2007-11-05 : 16:54:37
can you post some sample data from the table? and also expected output.

Dinakar Nethi
************************
Life is short. Enjoy it.
************************
http://weblogs.sqlteam.com/dinakar/
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-11-06 : 01:13:39
Post your question at Oracle Forums www.dbforums.com

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -