Advertisement
GabrielNexT

DbExchange - Original Query

Sep 20th, 2022 (edited)
1,145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PostgreSQL 4.38 KB | Source Code | 0 0
  1. SELECT
  2.     count(*)
  3. FROM public.reservation AS r
  4.          JOIN public.companyclient AS c
  5.               ON r.companyclientid = c.companyclientid
  6.          JOIN (SELECT r0.reservationitemid,
  7.                       r0.adultcount,
  8.                       r0.agreementname,
  9.                       r0.cancellationdate,
  10.                       r0.cancellationdescription,
  11.                       r0.checkindate,
  12.                       r0.checkinhour,
  13.                       r0.checkoutdate,
  14.                       r0.checkouthour,
  15.                       r0.childcount,
  16.                       r0.creationtime,
  17.                       r0.creatoruserid,
  18.                       r0.currencyid,
  19.                       r0.deleteruserid,
  20.                       r0.deletiontime,
  21.                       r0.estimatedarrivaldate,
  22.                       r0.estimateddeparturedate,
  23.                       r0.externalcomments,
  24.                       r0.externalreservationnumber,
  25.                       r0.extrabedcount,
  26.                       r0.extracribcount,
  27.                       r0.gratuityreasonid,
  28.                       r0.gratuitytypeid,
  29.                       r0.gratuitytypename,
  30.                       r0.integrationid,
  31.                       r0.internalcomments,
  32.                       r0.ischangeguest,
  33.                       r0.isdeleted,
  34.                       r0.ismigrated,
  35.                       r0.isnopost,
  36.                       r0.languagetocontact,
  37.                       r0.lastmodificationtime,
  38.                       r0.lastmodifieruserid,
  39.                       r0.mealplantypeid,
  40.                       r0.partnerreservationnumber,
  41.                       r0.rateplanid,
  42.                       r0.reasonid,
  43.                       r0.receivedroomtypeid,
  44.                       r0.receivedroomtypename,
  45.                       r0.requestedroomtypeid,
  46.                       r0.requestedroomtypename,
  47.                       r0.reservationid,
  48.                       r0.reservationidorigin,
  49.                       r0.reservationitemcode,
  50.                       r0.reservationitemidold,
  51.                       r0.reservationitemstatusid,
  52.                       r0.reservationitemuid,
  53.                       r0.roomid,
  54.                       r0.roomlayoutid,
  55.                       r0.roomnumber,
  56.                       r0.tenantid,
  57.                       r0.uhgrouperid,
  58.                       r0.walkin
  59.                FROM public.reservationitem AS r0
  60.                WHERE ((r0.tenantid = '025aa64f-67fb-4c23-b975-2b0fc3f5d65a') AND NOT (r0.isdeleted))
  61.                  AND r0.reservationitemstatusid NOT IN (6, 3, 7, 8)) AS t ON r.reservationid = t.reservationid
  62.          LEFT JOIN (SELECT b.billingaccountid,
  63.                       b.billingaccountname,
  64.                       b.billingaccounttypeid,
  65.                       b.blocked,
  66.                       b.businesssourceid,
  67.                       b.companyclientid,
  68.                       b.creationtime,
  69.                       b.creatoruserid,
  70.                       b.deleteruserid,
  71.                       b.deletiontime,
  72.                       b.enddate,
  73.                       b.groupkey,
  74.                       b.guestreservationitemid,
  75.                       b.internalcomments,
  76.                       b.invoicecomments,
  77.                       b.isdeleted,
  78.                       b.ismainaccount,
  79.                       b.lastmodificationtime,
  80.                       b.lastmodifieruserid,
  81.                       b.marketsegmentid,
  82.                       b.personheaderid,
  83.                       b.propertyid,
  84.                       b.rateplanid,
  85.                       b.reopeningdate,
  86.                       b.reopeningreasonid,
  87.                       b.reservationid,
  88.                       b.reservationitemid,
  89.                       b.startdate,
  90.                       b.statusid,
  91.                       b.tenantid
  92.                FROM public.billingaccount AS b
  93.                WHERE ((b.propertyid = '84') AND NOT (b.isdeleted))
  94.                  AND ((((((b.billingaccountid = b.groupkey) AND (b.companyclientid IS NOT NULL)) AND
  95.                          (b.billingaccounttypeid = '3')) AND (b.companyclientid IS NOT NULL)) AND
  96.                        (b.reservationid IS NOT NULL)) AND (b.statusid = '1'))) AS t0
  97.               ON (c.companyclientid = t0.companyclientid) AND (r.reservationid = t0.reservationid)
  98. WHERE ((r.propertyid = '84') AND NOT (r.isdeleted))
  99.   AND (r.companyclientid IS NOT NULL);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement