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.
Author |
Topic |
rjhe22
Constraint Violating Yak Guru
283 Posts |
Posted - 2013-12-19 : 08:26:08
|
hi i want to do a query like this SELECT * from dbo.SSCIRESOIHoldingsTable WHERE INV_SECTYPE_COD = '53' and BASE_MKT_VAL <0 but i want to add in where it pick up certain works in a field as wellso something like this SELECT * from dbo.SSCIRESOIHoldingsTable WHERE INV_SECTYPE_COD = '53' and BASE_MKT_VAL <0 and ltrim(ISS_LONG_NM) = 'CDS'left or right trim doesnt work anyone no what will |
|
James K
Master Smack Fu Yak Hacker
3873 Posts |
Posted - 2013-12-19 : 10:43:02
|
Didn't quite understand what you mean, but I am guessing that if the first 3 characters are "CDS", you want to pick up those. In that ase, the where clause should beAND ISS_LONG_NM LIKE 'CDS%' If there are prefixed spaces and you want to ignore them, then useAND LTRIM(ISS_LONG_NM) LIKE 'CDS%' |
|
|
king_fisher
Starting Member
13 Posts |
Posted - 2013-12-26 : 07:43:58
|
quote: Originally posted by rjhe22 hi i want to do a query like this SELECT * from dbo.SSCIRESOIHoldingsTable WHERE INV_SECTYPE_COD = '53' and BASE_MKT_VAL <0 but i want to add in where it pick up certain works in a field as wellso something like this SELECT * from dbo.SSCIRESOIHoldingsTable WHERE INV_SECTYPE_COD = '53' and BASE_MKT_VAL <0 and ltrim(ISS_LONG_NM) = 'CDS'left or right trim doesnt work anyone no what will
Go with this:SELECT * from dbo.SSCIRESOIHoldingsTable WHERE INV_SECTYPE_COD = '53' and BASE_MKT_VAL <0 and ISS_LONG_NM = LTRIM('CDS')vijay nelson |
|
|
|
|
|