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
 General SQL Server Forums
 New to SQL Server Programming
 Select Condition

Author  Topic 

satheesh
Posting Yak Master

152 Posts

Posted - 2011-08-04 : 09:26:22
Dear All,

I have 'Taveller' column in a policy table and the data in the field be

eg Mrs.Dolo Jaku, 72; Mr.Jame Jaku, 65;
Mr.Kate blitz, 22; Ms.sheva dove, 36;
Mr.James don, 22; Ms.Fleming don, 36; Mr.James Jaku, 65

I need to select all data from 'policy' table with condition

1.All Travellrs age be greater than 65
2.Any one travellers age be greater than 65

How to do this.Any help regarding this is highly appreciated.Many Thanks

Regards,
SG

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-08-04 : 09:30:50
you mean you store value as csv in a column? any reason why you're storing like this? Have you heard of normalisation and 1 NF in particular?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

satheesh
Posting Yak Master

152 Posts

Posted - 2011-08-04 : 10:01:14
Thanks for your reply Visakh.I need to reterive all policyid those corresponding traveller age be greater than 65.

Reagrds,
SG
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-08-04 : 10:06:25
is the values all in same column or in different columns?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

satheesh
Posting Yak Master

152 Posts

Posted - 2011-08-04 : 10:11:36
Thanks for your reply.All in same column 'traveller

for eg

Traveller (column)
Mrs.Dolo Jaku, 72; Mr.Jame Jaku, 65;
Mr.Kate blitz, 22; Ms.sheva dove, 36;
Mr.James don, 22; Ms.Fleming don, 36; Mr.James Jaku, 65

Result

Mrs.Dolo Jaku, 72; Mr.Jame Jaku, 65;

How to filter using age?I need to filter all traveller whose age is greater than 65

Regards,
SG
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-08-04 : 10:19:35
you've to parse the ; delimited text and get onto table and then do filtering. see below links for more info

http://visakhm.blogspot.com/2010/02/parsing-delimited-string.html
http://visakhm.blogspot.com/2010/01/multipurpose-apply-operator.html


------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -