Suraj Dubey

Suraj Dubey

  • 937
  • 839
  • 43.3k

How to combine result of two query in single return table in postgres

Mar 22 2022 10:14 AM

Hello friends,
 i am createing one function in which i am using dblink for connect two diffrenet database 
this is the smeple
 

SELECT *
 FROM   dblink('host=localhost port=5432 dbname=DB_Client user=postgres password=sa123','select "ClientId","StreetOne","StreetTwo" from "ClientAddress"')
 AS     c(id int,StreetOne text,StreetTwo text);
 

 SELECT *
 FROM dblink('host=localhost port=5432 dbname=DB_Quotes user=postgres password=sa123','select q."QuoteId",q."CreatedDate" ,q."Description",q."RateOpportunity",(p."Qty" * p."UnitCost") Total
     FROM "Quote" q 
     INNER JOIN "ProductOrservice" p
     ON q."QuoteId" = p."QuoteId"
     where q."ClientId"=1')
 AS c(quoteid integer,createddate character varying, description character varying, rateopportunity character varying, total integer);

This both query return table but i want to combine them in one table and return as result.
 


Answers (2)