title: Getting syntax error with Union sub query in Sybase DB
body: <p>We have a table ta_service with following data</p>
  
  <h2>Ref_id  &nbsp; &nbsp; &nbsp; &nbsp;  seq  &nbsp; &nbsp; &nbsp; &nbsp;    desc</h2>
  
  <p>2340     &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  1 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Service 1<br>
  2340     &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  2 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Offer 1<br>
  2340     &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  3 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Service 2<br>
  2340     &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  4 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Offer 2<br>
  2340     &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  5 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Service 3<br>
  2340     &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  5 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Service 4</p>
  
  <p>We have a requirement of fetching the services which has offers and we dont have any reference for getting this data apart from Ref_id(foreign key) and seq(Primary key) column.</p>
  
  <p>We tried to fetch by following query but failed with that. </p>
  
  <pre><code>SELECT * FROM ta_service
  WHERE Ref_id = 2340 AND seq IN ( 
      SELECT seq-1 AS seq
      FROM ta_service
      WHERE Ref_id = 2340
      AND desc LIKE '%Offer%'
  UNION 
      SELECT seq AS seq
      FROM ta_service
      WHERE Ref_id = 2340
      AND desc LIKE '%Offer%'
          ORDER BY seq) 
  </code></pre>
  
  <p>we are using sybase database. Any help appreciated</p>