pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Victor Yegorov <viy@nordlb.lv>
To: Abdul Wahab Dahalan <wahab@mimos.my>
Cc: pgsql-sql@postgresql.org
Subject: Re: SQl query
Date: Wed, 7 May 2003 11:57:28 +0300
Message-ID: <20030507085728.GQ17892@nordlb.lv> (raw)
In-Reply-To: <3EB8C1C5.4745E77E@mimos.my>
References: <3EB8C1C5.4745E77E@mimos.my>

* Abdul Wahab Dahalan <wahab@mimos.my> [07.05.2003 11:52]:
> If I've a transport table like this:
>  transporttype | transportid
> ---------------+-------------
>  Lorry         |        1037
>  Pickup        |        1038
>  Lorry         |        1040
>  Lorry         |        1045
>  Pickup        |        1046
>  Lorry         |        1047
> 
> How do I make a query so that I get a result like
> 
>  transporttype | #of transport
> ---------------+-------------
>  Lorry            |        4
>  Pickup          |        2

select
	transporttype,
	count(transporttype)
from
	your_table
group by
	transporttype;


-- 

Victor Yegorov

view thread (18+ messages)  latest in thread

Message-ID: <20030507085728.GQ17892@nordlb.lv>
Permalink:  ../20030507085728.GQ17892@nordlb.lv/
Also on:    postgresql.org/message-id/20030507085728.GQ17892@nordlb.lv

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: viy@nordlb.lv, wahab@mimos.my
  Subject: Re: SQl query
  In-Reply-To: <20030507085728.GQ17892@nordlb.lv>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox