Naveen Yadav
Naveen Yadav

Reputation: 5

Create a Db2 SQL Query that would give a same result as Postgresql query

I am migrating from PostgreSql to DB2 and I have a query from postgresql ie.

select (
  select count(distinct gs_receiver_id) 
  from AMERISOURCEPROTOTYPE.transactions 
  WHERE first_touch_day = '2020-02-19' 
    AND transaction_type = '850' 
    AND company = 'Customer' 
    AND direction = 'O'
) as count1

I need to create a similar query in DB2 which gives the same result . Can somebody Please help ?

Upvotes: 0

Views: 38

Answers (1)

Gordon Linoff
Gordon Linoff

Reputation: 1269923

The subquery seems unnecessary. Assuming the data is the same and the types compatible:

select count(distinct gs_receiver_id) as count1
from AMERISOURCEPROTOTYPE.transactions 
where first_touch_day = '2020-02-19' and
      transaction_type = '850' and
      company = 'Customer' and
      direction = 'O'

Upvotes: 2

Related Questions