Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dlFoX-0007hB-VA for pgsql-performance@arkaria.postgresql.org; Fri, 25 Aug 2017 14:42:26 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1dlFoX-0003sA-D8 for pgsql-performance@arkaria.postgresql.org; Fri, 25 Aug 2017 14:42:25 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1dlFoW-0003s1-S4 for pgsql-performance@postgresql.org; Fri, 25 Aug 2017 14:42:25 +0000 Received: from mail-qk0-x22f.google.com ([2607:f8b0:400d:c09::22f]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84_2) (envelope-from ) id 1dlFoT-0003bZ-Qc for pgsql-performance@postgresql.org; Fri, 25 Aug 2017 14:42:23 +0000 Received: by mail-qk0-x22f.google.com with SMTP id a77so38696qkb.1 for ; Fri, 25 Aug 2017 07:42:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=C80gHvfLlbd8qzjD+Si8iviNZ5gMLQjk2m+LaaxAzS4=; b=Vw8z1QD3Fc/+aRDMPbvr5qDDlUyZHe4HMrucEEUww569uh3gb0NbYU2lgZ7ow51D16 XfKrnfCPgV51bpFWw+VVUrACqCJDxVfQO1XpVCnlifcwNJwDUHU1LmDmXYJCURH0sRQH 1PjXXpNdkjfrX4ECkzD51Um70iOWPyn1xZVSATzilLgIQsADif1QY/tkBELiEQ4SUcPO eJEU23D9CZ62myh0+1ZTmJdXF/6EUqqUWDIW5KXKf1Uktb+hiUpfbP3EDDTuczzeEQD1 APVrTfsjVENGlydi45Gw52XQPyTlg4A/Tle2VisDcYqaRHS6wAL2Fhrf8KheeoppLNMz lOmg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=C80gHvfLlbd8qzjD+Si8iviNZ5gMLQjk2m+LaaxAzS4=; b=EXQgOrHr/5HSOKN6ezGTANuLlHBTA4tSVLjaWicBd15UFlJ3PioiJH8KJZTlxHEwgh JsohEOwAPn4f7wP26IVfVm3qludSdD8mnsGWN5xapHgGn5eOsDMJ7g+iWeiF8Q/VVSmO qbEZjxXrq4TTP4e0iS9f3m8UVVH6YU4vyYbtpKpoqHnNl/y2mXghQZ4uW6j+Osd3yyxb 9h7HZVcFw3oF1jKsM9dz56Sx2cvGlC3PcssIpJDOzQhAL9vmP2bpOMqj2m/Qs5bKdvtp +g4NDX2FXqlA50ntwGN+p+tMLDzNqn0iovCRpLqekESvDHl9lV0hmZZJgq9cRBT+DAfB GOYg== X-Gm-Message-State: AHYfb5hVJaQ2dxUt1LF6w/06Bmm1ulPIOSli+Vcs+Fg327DeQ6CFi1cO LMLarcC0c2BSxe/8gCvHq8l4tqKynz01 X-Received: by 10.55.65.134 with SMTP id o128mr14556025qka.161.1503672140919; Fri, 25 Aug 2017 07:42:20 -0700 (PDT) MIME-Version: 1.0 Received: by 10.12.193.209 with HTTP; Fri, 25 Aug 2017 07:42:20 -0700 (PDT) In-Reply-To: <8476a0511c074ddd9eaf15a3eb2e71ce@cyient.com> References: <8476a0511c074ddd9eaf15a3eb2e71ce@cyient.com> From: "David G. Johnston" Date: Fri, 25 Aug 2017 07:42:20 -0700 Message-ID: Subject: Re: Hi To: Daulat Ram Cc: "pgsql-performance@postgresql.org" Content-Type: multipart/alternative; boundary="001a1148a0bed17bad055794f39f" List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-performance Precedence: bulk Sender: pgsql-performance-owner@postgresql.org --001a1148a0bed17bad055794f39f Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Thu, Aug 24, 2017 at 11:49 PM, Daulat Ram wrote: > Hello, > > > > Would I request to help me on this query. > > > > SELECT 'Inspection Completed' as "ALL Status" ,COUNT(*) as "Number of > Count" FROM ud_document WHERE status =3D 'Inspection Completed' union SEL= ECT > 'Pending', COUNT(*) FROM ud_document WHERE status =3D 'Pending' union SEL= ECT > 'Approved', COUNT(*) FROM ud_document WHERE status =3D 'Approved' union > SELECT 'Rejected', COUNT(*) FROM ud_document WHERE status =3D 'Rejected' > union SELECT 'Payment Due',count(*) from ud_document where payment_status= =3D > 'Payment Due' union SELECT 'Payment Done' ,count(*) from ud_document wher= e > payment_status =3D 'Payment Done' > > > > And now I want to exclude the uniqueid=3D '201708141701018' from the abov= e > query. how it can be ??? > > > =E2=80=8BYour use of UNION here seems necessary. Just write a normal GROUP= BY aggregation query. You might need to get a bit creative since you are collapsing status and payment_status into a single column. "CASE ... WHEN ... THEN ... ELSE ... END" is quite helpful for doing stuff like that. For now I'll just leave them as two columns. =E2=80=8BSELECT status, payment_status, count(*) FROM ud_document WHERE uniqueid <> '201708141701018' GROUP BY 1, 2; David J. --001a1148a0bed17bad055794f39f Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
On Thu, Au= g 24, 2017 at 11:49 PM, Daulat Ram <Daulat.Ram@cyient.com> wrote:

Hello, <= /span>

=C2=A0

Would I request to hel= p me on this query.

=C2=A0

SELECT 'Inspection= Completed' as "ALL Status" ,COUNT(*) as "Number of Coun= t" FROM ud_document WHERE status =3D 'Inspection Completed' un= ion SELECT 'Pending', COUNT(*) FROM ud_document WHERE status =3D &#= 39;Pending' union SELECT 'Approved', COUNT(*) FROM ud_document WHERE status =3D '= ;Approved' union SELECT 'Rejected', COUNT(*) FROM ud_document W= HERE status =3D 'Rejected' union SELECT 'Payment Due',count= (*) from ud_document where payment_status =3D 'Payment Due' union S= ELECT 'Payment Done' ,count(*) from ud_document where payment_status =3D 'Payment= Done'=C2=A0

=C2=A0

And now I want to excl= ude the uniqueid=3D '201708141701018' from the above query. how it = can be ???



=E2=80=8BYour use of UNION here seems necessary.=C2=A0 Just write a nor= mal GROUP BY aggregation query.=C2=A0 You might need to get a bit creative = since you are collapsing status and payment_status into a single column. = =C2=A0"CASE ... WHEN ... THEN ... ELSE ... END" is quite helpful = for doing stuff like that.=C2=A0 For now I'll just leave them as two co= lumns.

=E2=80=8BSELECT status, payment_status,= count(*)
FROM ud_document
WHERE uniqueid <> '20= 1708141701018'
GROUP BY 1, 2;

David J.
--001a1148a0bed17bad055794f39f--