• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to Use Condition in SQL

 
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Here this query gives location of first occurance of letter 'A' in the name.

select
(posstr(t1.NAME,'A')) as Location, t1.Name from vista.VFZPVACCOUNTANT t1


------------ OUTPUT ------------------

LOCATION NAME
----------- --------------------------
0 test
14 Kuhn Handels AG

-------------------------------------
-------------------------------------

I want to select only "Non Zero" location records. Means There should be atleast one 'A' or 'a' in the name.

So that in the output there should be only second record.

I am working on Db2 database Can ne one help.

Thanks in advance,
Dhiraj Srivastava
 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Please user where clause in your query

select
(posstr(t1.NAME,'A')) as Location, t1.Name from vista.VFZPVACCOUNTANT t1

where Location > 0
 
Marshal
Posts: 79180
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Surely you mean

. . . WHERE location >= 0

?
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic