Re: [SQL] count function alternative in postgres

2010-04-26 Thread junaidmalik14
Thanks Ben. It works fine. Junaid. Ben Morrow-2 wrote: > > Quoth junaidmali...@gmail.com (junaidmalik14): >> >> Is there any alternative of mysql function COUNT(DISTINCT expr,[expr...]) >> in >> postgres. We get error if we >> >> write count like this count(distinct profile.id, profile.name

Re: [SQL] count function alternative in postgres

2010-04-26 Thread junaidmalik14
Thanks tkellerer. Junaid tkellerer wrote: > > junaidmalik14 wrote on 03.04.2010 14:58: >> >> Is there any alternative of mysql function COUNT(DISTINCT expr,[expr...]) >> in >> postgres. We get error if we >> >> write count like this count(distinct profile.id, profile.name, >> profile.age) >> but

Re: [SQL] count function alternative in postgres

2010-04-06 Thread Ben Morrow
Quoth junaidmali...@gmail.com (junaidmalik14): > > Is there any alternative of mysql function COUNT(DISTINCT expr,[expr...]) in > postgres. We get error if we > > write count like this count(distinct profile.id, profile.name, profile.age) > but it works well in mysql. Pg does support COUNT(DIST

Re: [SQL] count function alternative in postgres

2010-04-06 Thread Thomas Kellerer
junaidmalik14 wrote on 03.04.2010 14:58: Is there any alternative of mysql function COUNT(DISTINCT expr,[expr...]) in postgres. We get error if we write count like this count(distinct profile.id, profile.name, profile.age) but it works well in mysql. Reference url is given below http://dev.my

[SQL] count function alternative in postgres

2010-04-06 Thread junaidmalik14
Is there any alternative of mysql function COUNT(DISTINCT expr,[expr...]) in postgres. We get error if we write count like this count(distinct profile.id, profile.name, profile.age) but it works well in mysql. Reference url is given below http://dev.mysql.com/doc/refman/5.1/en/group-by-functi

Re: [SQL] count(distinct)

2009-02-06 Thread Richard Huxton
Zdravko Balorda wrote: > this is probably an old issue but I'm not all that experienced. > > I wonder if an index can be accessed rather directly, as to speed up > a query like "select count(distinct())", by simply calculating the > number of branches (leaves) an index has. Or at least to skip sor

[SQL] count(distinct)

2009-02-06 Thread Zdravko Balorda
Hi, this is probably an old issue but I'm not all that experienced. I wonder if an index can be accessed rather directly, as to speed up a query like "select count(distinct())", by simply calculating the number of branches (leaves) an index has. Or at least to skip sorting. Best regards, Zdr

Re: [SQL] count question

2008-04-08 Thread ashish
Volkan YAZICI wrote: > On Wed, 9 Apr 2008, novice <[EMAIL PROTECTED]> writes: > >> Is it possible to write a query to produce: >> >> meter_id | no_of_bays | bay_id >> --++--- >> 5397 | 2 | 5397-01 >> 5397 | 2 | 5397-02 >> 5409 |

Re: [SQL] count question

2008-04-08 Thread Volkan YAZICI
On Wed, 9 Apr 2008, novice <[EMAIL PROTECTED]> writes: > Is it possible to write a query to produce: > > meter_id | no_of_bays | bay_id > --++--- > 5397 | 2 | 5397-01 > 5397 | 2 | 5397-02 > 5409 | 3 | 5409-01 > 5409

Re: [SQL] count question

2008-04-08 Thread rdeleonp
On 4/8/08, Craig Ringer <[EMAIL PROTECTED]> wrote: > novice wrote: > > > Is it possible to write a query to produce: > > > > meter_id | no_of_bays | bay_id > > --++--- > > 5397 | 2 | 5397-01 > > 5397 | 2 | 5397-02 > > 5409 |

Re: [SQL] count question

2008-04-08 Thread Craig Ringer
novice wrote: > Is it possible to write a query to produce: > > meter_id | no_of_bays | bay_id > --++--- > 5397 | 2 | 5397-01 > 5397 | 2 | 5397-02 > 5409 | 3 | 5409-01 > 5409 | 3 | 5409-02 > 5409 |

[SQL] count question

2008-04-08 Thread novice
i have a table CREATE TABLE meter ( meter_id integer NOT NULL, no_of_bays integer, CONSTRAINT meter_pkey PRIMARY KEY (meter_id) ) INSERT INTO meter( meter_id, no_of_bays) VALUES (5397, 2); INSERT INTO meter( meter_id, no_of_bays) VALUES (5409, 3); select

Re: [SQL] Count of rows

2007-08-03 Thread Christian Kindler
do this via execute in a stored procedure - something like this (written on the flow - untested!) returns setof text declare my_record record; my counter as bigint; begin for my_record in select tablename from pg_tables where schemaname = 'public' loop execute into counter

[SQL] Count of rows

2007-08-02 Thread Paul Lambert
What's the best way to count how many rows are in each table via SQL? Or is it even possible? I'm trying something like: select tablename, count(*) from (select tablename from pg_tables where schemaname = 'public') as test group by tablename; But obviously this just gives a count of 1 for ea

Re: [SQL] Count rows by day interval

2007-05-10 Thread chester c young
> ... instead of date_trunc('day',sent_messages.date) why don't you have a function that takes four three arguments: - beginning date of query - interval, ie, reminder_services.activity_days_min - timestamp, ie, sent_messages.date have it return the minimum date for that interval as I think I u

[SQL] Count rows by day interval

2007-05-10 Thread Loredana Curugiu
Dear all, I have the following 3 tables: TABLE 1: themes uid | theme -+ 1 | HOME 2 | BILL 3 | ERROR 4 | ACTION 5 | ANA 6 | LIA 7 | MIA TABLE 2: reminder_services uid | theme_uid | activity_min_days | activity_max_months -++

[SQL] Count field in query

2006-12-06 Thread lucas
Hi all. Is there any way to build a query with a field that has the IndexCount of the query. It's something like the number of the row returned (starting with 1). Something like: select * from mytable order by name; id | name | CountField 7 | KK | 1 98 | LL | 2 5 | ZZ

Re: [SQL] Count and list only where count is bigger than 1

2006-09-19 Thread A. Kretschmer
am Tue, dem 19.09.2006, um 12:04:55 -0300 mailte Ezequias Rodrigues da Rocha folgendes: > Hi list, > > It is possible to make a count select and only display where count column is > bigger than 1 ? > > My SQL is like this > > SELECT distinct cli.bairro, COUNT( * ) as qtd > FROM base.cliente cl

Re: [SQL] Count and list only where count is bigger than 1

2006-09-19 Thread bnichols
> Hi list, > > It is possible to make a count select and only display where count column > is > bigger than 1 ? > > My SQL is like this > > SELECT distinct cli.bairro, COUNT( * ) as qtd > FROM base.cliente cli > GROUP BY cli.cidade, cli.bairro > ORDER BY 2 > > I noticed that I cannot use "where qtd

Re: [SQL] Count and list only where count is bigger than 1

2006-09-19 Thread Mezei Zoltán
Ezequias Rodrigues da Rocha wrote: SELECT distinct cli.bairro, COUNT( * ) as qtd FROM base.cliente cli GROUP BY cli.cidade, cli.bairro ORDER BY 2 I noticed that I cannot use "where qtd > 1" ok ? What to do ? Google/read tutorial for HAVING. E.g. SELECT distinct cli.bairro, COUNT( * )

[SQL] Count and list only where count is bigger than 1

2006-09-19 Thread Ezequias Rodrigues da Rocha
Hi list,It is possible to make a count select and only display where count column is bigger than 1 ?My SQL is like thisSELECT distinct cli.bairro, COUNT( * ) as qtdFROM base.cliente cliGROUP BY cli.cidade, cli.bairroORDER BY 2I noticed that I cannot use "where qtd > 1" ok ?What to do ?Regards ...-

Re: [SQL] count array in postgresql

2005-03-06 Thread Michael Fuhr
On Mon, Mar 07, 2005 at 09:09:57AM +0700, bandeng wrote: > I still cannot find count function in that reference. See array_upper() and array_lower(). -- Michael Fuhr http://www.fuhr.org/~mfuhr/ ---(end of broadcast)--- TIP 5: Have you checked our

Re: [SQL] count array in postgresql

2005-03-06 Thread Sean Davis
How about array_dims? It looks like you will still have to do a string split, but Sean - Original Message - From: "bandeng" <[EMAIL PROTECTED]> To: Sent: Sunday, March 06, 2005 9:09 PM Subject: Re: [SQL] count array in postgresql my Postgresql version is 7.4 I s

Re: [SQL] count array in postgresql

2005-03-06 Thread bandeng
my Postgresql version is 7.4 I still cannot find count function in that reference. but I try to use like this just checking the array value is null or not, it's work but dunno it is the good way or not. for example, vararray := {ab,cd,ef,gh} i := 1; while vararray[i] is not null loop i :=

Re: [SQL] count array in postgresql

2005-03-06 Thread Michael Fuhr
On Sun, Mar 06, 2005 at 11:54:15PM +0700, bandeng wrote: > I need some help, I have created function with argument in array. > I already try to find array function in manual but failed. Maybe you're looking for "Array Functions and Operators" in the "Functions and Operators" chapter. You don't s

[SQL] count array in plpgsql

2005-03-06 Thread bandeng
hello guys, I need some help, I have created function with argument in array. I already try to find array function in manual but I cant. so is there any solution to counting array value and looping array value? any some language usually use count($array) Thank in a bunch Ricky Wibowo -- Gutten

[SQL] count array in postgresql

2005-03-06 Thread bandeng
hello guys, I need some help, I have created function with argument in array. I already try to find array function in manual but failed. so is there any solution to counting array value and looping array value? some language usually use count($array) Thank in a bunch Ricky ---

Re: [SQL] Count Columns

2005-02-16 Thread Bruno Wolff III
On Wed, Feb 16, 2005 at 10:09:05 -0800, Ray Madigan <[EMAIL PROTECTED]> wrote: > > Is there a way to count the number of null or not null columns in a row and > have an output column that has that count as the value? One way to do this would be to create a CASE clause for each column that retur

[SQL] Count Columns

2005-02-16 Thread Ray Madigan
I haven't done very many complex queries in sql, and maybe Im thinking about my problem wrong but: Is there a way to count the number of null or not null columns in a row and have an output column that has that count as the value? I want to create a ranking of the row based upon the number of not

Re: [SQL] count record in plpgsql

2004-11-29 Thread Richard Huxton
Nurdin wrote: how can i know the count of record in plpgsql.example if i'm query with query komponent from delphi i will know the record count of record.but how with plpgsql. GET DIAGNOSTICS integer_var = ROW_COUNT; See the manual for details (plpgsql section, "Obtaining the result status"). HTH --

Re: [SQL] count record in plpgsql

2004-11-29 Thread Tomasz Myrta
how can i know the count of record in plpgsql.example if i'm query with query komponent from delphi i will know the record count of record.but how with plpgsql. any ideas? Is it what you need: GET DIAGNOSTICS n = ROW_COUNT; after executing query ? Regards, Tomasz Myrta

[SQL] count record in plpgsql

2004-11-28 Thread Nurdin
how can i know the count of record in plpgsql.example if i'm query with query komponent from delphi i will know the record count of record.but how with plpgsql.   any ideas?   thnx best and regard   nurdin

Re: [SQL] COUNT(*) to find records which have a certain number of

2004-09-26 Thread Martin Knipper
Am 20.09.2004 18:19 schrieb T E Schmitz: > I figured it eventually. (The only thing I don't know is where to put > the ORDER BY.) > > >>I want to select only those BRAND/MODEL combinations, where the MODEL >>has more than one TYPE, but only where one of those has TYPE_NAME='xyz'. >>I am not int

Re: [SQL] COUNT(*) to find records which have a certain number of

2004-09-20 Thread Chester Kustarz
On Mon, 20 Sep 2004, T E Schmitz wrote: > I was feeling a bit guilty about posting such a trivial question. I can > cobble together some straightforward SQL but I could really do with a > source of more complex SQL examples. > If you know of any links - that would great and save the list from more

Re: [SQL] COUNT(*) to find records which have a certain number of dependencies ?

2004-09-20 Thread Greg Stark
T E Schmitz <[EMAIL PROTECTED]> writes: > ) as somealias on (model_fk = model_pk) > > (subquery in FROM must have an alias) ARGH! This is one of the most annoying things about postgres! It bites me all the time. Obviously it's totally insignificant since it's easy for my to just throw an "AS x"

Re: [SQL] COUNT(*) to find records which have a certain number of

2004-09-20 Thread T E Schmitz
Hello Greg, You have given me plenty of food for thought. Thank you for taking the time. Currently, the tables have such few records (350, 900, 1000) that performance does not come into it, particularly seeing as this was only needed for a one-shot report. However, I have stached your examples a

Re: [SQL] COUNT(*) to find records which have a certain number of

2004-09-20 Thread Greg Stark
T E Schmitz <[EMAIL PROTECTED]> writes: > SELECT > BRAND_NAME,MODEL_NAME ... > intersect ... Huh, I never think of the set operation solutions. I'm curious how it compares speed-wise. -- greg ---(end of broadcast)--- TIP 5: Have you checked our

Re: [SQL] COUNT(*) to find records which have a certain number of dependencies ?

2004-09-20 Thread Greg Stark
T E Schmitz <[EMAIL PROTECTED]> writes: > I want to select only those BRAND/MODEL combinations, where the MODEL has more > than one TYPE, but only where one of those has TYPE_NAME='xyz'. > I am not interested in MODELs with multiple TYPEs where none of them are called > 'xyz'. There are lots of

Re: [SQL] COUNT(*) to find records which have a certain number of

2004-09-20 Thread T E Schmitz
Hi Rod, Rod Taylor wrote: On Mon, 2004-09-20 at 12:19, T E Schmitz wrote: I figured it eventually. (The only thing I don't know is where to put the ORDER BY.) Try this: SELECT brand_name, model_name FROM (SELECT ... INTERSECT SELECT ...) AS t ORDER BY ... That do

Re: [SQL] COUNT(*) to find records which have a certain number of

2004-09-20 Thread Rod Taylor
On Mon, 2004-09-20 at 12:19, T E Schmitz wrote: > I figured it eventually. (The only thing I don't know is where to put > the ORDER BY.) Try this: SELECT brand_name, model_name FROM (SELECT ... INTERSECT SELECT ...) AS t ORDER BY ... ---

Re: [SQL] COUNT(*) to find records which have a certain number of

2004-09-20 Thread T E Schmitz
I figured it eventually. (The only thing I don't know is where to put the ORDER BY.) I want to select only those BRAND/MODEL combinations, where the MODEL has more than one TYPE, but only where one of those has TYPE_NAME='xyz'. I am not interested in MODELs with multiple TYPEs where none of them a

[SQL] COUNT(*) to find records which have a certain number of dependencies ?

2004-09-20 Thread T E Schmitz
Hello, I apologize in advance for this garbled message but I've been banging my head against a brick-wall for a while and I just can't figure how to do the following: I have 3 tables BRAND,MODEL,TYPE which are related to each other: BRAND = BRAND_PK BRAND_NAME MODEL = MODEL_PK MODEL_NAME

Re: [SQL] COUNT on a DISTINCT query

2004-05-07 Thread Suller András
SELECT COUNT(xxx.*) FROM () xxx This cause an error for me: ERROR: cannot pass result of subquery or join "xxx" to a function Try this instead: SELECT COUNT(*) FROM () xxx It worked for me. Regards, Suller Andras ---(end of broadcast)--- TIP 5: Have

[SQL] COUNT on a DISTINCT query

2004-05-05 Thread Freddy Villalba Arias
Hello everybody,   I’m a newbie to PostgreSQL.   I have the following query:   SELECT DISTINCT (at.*) FROM AGRUPACION_TERRITORIAL at, LINK_AGRUP_TE_MUNICIPIO link, MUNICIPIO m, PROVINCIA p, CCAA c WHERE at.agru_id_agrupacion_t = link.agmu_id_agrupacion_t AND link.agmu

[SQL] count(*) from cursor

2004-01-17 Thread Yuri Gordienko
Hi, How can I get a count(*) records from cursor? Thank's __ Best regards, Yuri Gordienko begin:vcard fn;quoted-printable:=D0=AE=D1=80=D0=B8=D0=B9 =D0=93=D0=BE=D1=80=D0=B4=D0=B8=D0=B5=D0=BD=D0=BA= =D0=BE n;quoted-printable;quoted-printable:=D0=93=D0=BE=D1=80=D0=B4=D0=B8=D0=B5=D0=BD=D0=BA=D0=BE;

Re: [SQL] Count dates distinct within an interval

2003-07-15 Thread Stuart
Dmitry Tkach wrote: Hi, everybody! I was trying to formulate a sql query, that I now think is impossible :-( I just thought, I'd run it by you before I give up - perhaps, you guys would have some ideas... Suppose, I have a table like this create table test ( stuff int, stamp timestamp ); No

Re: [SQL] Count dates distinct within an interval

2003-07-15 Thread greg
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 > Also, I could certainly write a simple function, that would get all the > entries in order, and scan through them, counting according to my rules... > But I was hoping to find some way to do this in plain sql though... In this example, you are be

Re: [SQL] Count dates distinct within an interval

2003-07-15 Thread Dmitry Tkach
You need to elaborate on your logic some more, and state exactly what you would want in the A,B,C case above. Does B get lumped with A or with C? It is within 24 hours of both, after all. Does C not get lumped in with B simply because B has already been lumped in with A? Yes. The first (earli

Re: [SQL] Count dates distinct within an interval

2003-07-15 Thread greg
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 > Now, I want to count the occurences of each value of stuff in the table, > but so that entries within 24 hours from each other count as one... >... > A = 2001 - 01- 01 20:20:00 > B = 2001 - 01 - 02 20:19:00 > C = 2001 - 01 - 02 20:21:00 > Should

[SQL] Count dates distinct within an interval

2003-07-15 Thread Dmitry Tkach
Hi, everybody! I was trying to formulate a sql query, that I now think is impossible :-( I just thought, I'd run it by you before I give up - perhaps, you guys would have some ideas... Suppose, I have a table like this create table test ( stuff int, stamp timestamp ); Now, I want to count t

Re: [SQL] count(*) optimization

2003-01-08 Thread Josh Berkus
Nikola, > I am not sure pgAdmin uses count(*) and I didn't have time to check > phpPgAdmin also, I presumed it from similarly slow response I get in > psql Well, pgAdmin and phpPgAdmin have their own mailing lists. I'd suggest posting there. Ideally, these programs should have an option that l

Re: [SQL] count(*) optimization

2003-01-08 Thread Nikola Ivacic
> Cc: <[EMAIL PROTECTED]> Sent: Wednesday, January 08, 2003 5:20 PM Subject: Re: [SQL] count(*) optimization Bummer. I seem to remember PGAccess using the numbers generated by ANALYZE to show the number of records. I noticed it was inaccurate until you ran a vaccum. I guess pgAdmin chose

Re: [SQL] count(*) optimization

2003-01-08 Thread Nikola Ivacic
ECTED]> Sent: Wednesday, January 08, 2003 5:22 PM Subject: Re: [SQL] count(*) optimization > On Wed, Jan 08, 2003 at 17:04:40 +0100, > Nikola Ivacic <[EMAIL PROTECTED]> wrote: > > Hi > > > > I have trouble executing count(*) statement. > > On a large data

Re: [SQL] count(*) optimization

2003-01-08 Thread Bruno Wolff III
On Wed, Jan 08, 2003 at 17:04:40 +0100, Nikola Ivacic <[EMAIL PROTECTED]> wrote: > Hi > > I have trouble executing count(*) statement. > On a large dataset it takes quite a while to return result. > Is there any other way to get number of tupples in relation > or is the only way to optimize cou

[SQL] count(*) optimization

2003-01-08 Thread Nikola Ivacic
Hi   I have trouble executing count(*) statement. On a large dataset it takes quite a while to return result. Is there any other way to get number of tupples in relation or is the only way to optimize count() function to index it?    thanks   Nikola

Re: [SQL] COUNT DISTINCT?

2002-07-30 Thread Josh Berkus
Stephan, > Would that be the same as: > select count(distinct skip_date) from weekend_list > where ... Yeah, that would be what I was looking for. -- -Josh Berkus Aglio Database Solutions San Francisco ---(end of broadcast)--- TIP 4: Don't '

Re: [SQL] COUNT DISTINCT?

2002-07-30 Thread Stephan Szabo
On Tue, 30 Jul 2002, Josh Berkus wrote: > Folks, > > Anybody know a keen shortcut for the following: > > SELECT count(skip_date) > FROM (SELECT DISTINCT skip_date FROM weekend_list > WHERE ... ...) days_to_skip; > > That's a double aggregate, and is bound to be dog-slow. Would tha

Re: [SQL] COUNT func

2001-10-18 Thread Bhuvan A
hi, try this too.. select count(*),age,status from person where age=40 and status='MARRIED' group by age,status; Regards, Bhuvaneswar. On Oct 18, Oleg Lebedev wrote: > Hi, > I am trying to count the number or rows in a table with similar field > values. I want to do it in one table sca

Re: [SQL] COUNT func

2001-10-18 Thread Stephan Szabo
On Thu, 18 Oct 2001, Oleg Lebedev wrote: > Hi, > I am trying to count the number or rows in a table with similar field > values. I want to do it in one table scan. > In other words, say I want to count the number of rows in Person table, > having age equal to 40, and the number of rows with stat

Re: [SQL] COUNT func

2001-10-18 Thread Oleg Lebedev
It worked! I checked the query plan it generates, and it's really a one-pass scan. thanks, Oleg Stephan Szabo wrote: > On Thu, 18 Oct 2001, Oleg Lebedev wrote: > > > Hi, > > I am trying to count the number or rows in a table with similar field > > values. I want to do it in one table scan. > >

[SQL] COUNT func

2001-10-18 Thread Oleg Lebedev
Hi, I am trying to count the number or rows in a table with similar field values. I want to do it in one table scan. In other words, say I want to count the number of rows in Person table, having age equal to 40, and the number of rows with status as 'married'. I want Person table to be scanned on

[SQL] count(*) and limit

2001-10-15 Thread Orion
I have a interface where users are paging through results of a query. In order to do so I need to select count(*) from data where stuff; To find out how many pages of data there are ( needed for the navigation bar) and then I need to select * from data where stuff limit X offset y; Now,

Re: [SQL] count(*)

2001-07-03 Thread Tom Lane
>> You probably mean: >> select car, tit, (select count(*) from auto) from auto I think he probably wants select car, tit, count(*) from auto group by car, tit regards, tom lane ---(end of broadcast)--- TIP 6: Have

Re: [SQL] count() and multiple tables

2001-03-19 Thread Josh Berkus
Stephan, Joseph, > Because d.id was guaranteed to be unique, you might be able to > count(distinct d.id) and get the result you want. [I think the > subquery is a nicer way of representing it] Plus a several SQL implementations don't implement the DISTINCT until after the COUNT, reuslting in a

Re: [SQL] count() and multiple tables

2001-03-19 Thread Stephan Szabo
> > And postgres tries to be helpful again... :( [I *really* dislike this > > adding to from list thing] Technically the above should be illegal > > because no from list contains u or a. Postgres is adding them to the > > from list for you. > > > I get the same result if I do: > select count(d

Re: [SQL] count() and multiple tables

2001-03-19 Thread Stephan Szabo
On Mon, 19 Mar 2001, Joseph Shraibman wrote: > I want to select all the entries from d that have at least one > corresponding entry in u that meets my conditions. The problem is that > count(*) is returning the number of corresponding entries in u, and I > want only the number of entries in d.

Re: [SQL] count() and multiple tables

2001-03-19 Thread Joseph Shraibman
Stephan Szabo wrote: > > On Mon, 19 Mar 2001, Joseph Shraibman wrote: > > > I want to select all the entries from d that have at least one > > corresponding entry in u that meets my conditions. The problem is that > > count(*) is returning the number of corresponding entries in u, and I > > wan

Re: [SQL] count() and multiple tables

2001-03-19 Thread Josh Berkus
Joseph, SImple as pie (e.g., easy on your 100th one): > select count(*) from d where status = 2 and d.id = u.dkey and > u.status = > 2 and not u.b and u.akey = a.key and a.status = 3; Count(*) will always count the number of records in the largest table in your join. If you want the nu

[SQL] count() and multiple tables

2001-03-19 Thread Joseph Shraibman
I want to select all the entries from d that have at least one corresponding entry in u that meets my conditions. The problem is that count(*) is returning the number of corresponding entries in u, and I want only the number of entries in d. How do I do this? create table d( id

Re: [SQL] count number of weeks??

2001-03-05 Thread Christopher Sawtell
On Tue, 06 Mar 2001 06:55, [EMAIL PROTECTED] wrote: > Hi all! > I wonder how in PG7.0.2 I can count the number of weeks from a date > field that I have in a table, lets say: > > table trial has in its fields start_date as sysdate(), and now I want to > do a select that will give me the number of w

[SQL] count number of weeks??

2001-03-05 Thread rocael
Hi all! I wonder how in PG7.0.2 I can count the number of weeks from a date field that I have in a table, lets say: table trial has in its fields start_date as sysdate(), and now I want to do a select that will give me the number of weeks from now [sysdate()] to the start_date. Thanks for the he

Re: [SQL] count( distinct x )

2000-11-27 Thread Tom Lane
Anthony <[EMAIL PROTECTED]> writes: > I think it's time to get Mr. Sysadmin to upgrade to v7 ;) That's a good idea on many grounds, not only this one ;-) However, if you really need a 6.5.* solution, you could do SELECT DISTINCT foo INTO TEMP TABLE mytemp FROM ... SELECT COUNT(*

Re: [SQL] count( distinct x )

2000-11-27 Thread Anthony
Kenn Thompson wrote: > Ok- messy, but it works > > CREATE VIEW testview AS > select distinct area from areapostcode where postcode like 'BS1%'; > > SELECT COUNT(*) FROM testview; > > kenn > > >>> Anthony <[EMAIL PROTECTED]> 11/27/00 01:07PM >>> > Kenn Thompson wrote: > > > What about > > > >

Re: [SQL] count( distinct x )

2000-11-27 Thread Anthony
Najm Hashmi wrote: > Anthony wrote: > > > Michael Fork wrote: > > > > > I think you want > > > > > > SELECT count(distinct(area)) FROM areapostcode WHERE postcode LIKE 'BS1%' > > > > > > > psql still not happy :( > > > > SELECT count(distinct(area)) FROM areapostcode WHERE postcode LIKE 'BS1%'; >

Re: [SQL] count( distinct x )

2000-11-27 Thread Anthony
Tom Lane wrote: > Anthony <[EMAIL PROTECTED]> writes: > > select count( distinct area ) from areapostcode where postcode like > > 'BS1%' > > the above statement fails with > > ERROR: parser: parse error at or near "distinct" > > What Postgres version are you running? Support for count(d

Re: [SQL] count( distinct x )

2000-11-27 Thread Tom Lane
Anthony <[EMAIL PROTECTED]> writes: > select count( distinct area ) from areapostcode where postcode like > 'BS1%' > the above statement fails with > ERROR: parser: parse error at or near "distinct" What Postgres version are you running? Support for count(distinct foo) was added in 7.0,

Re: [SQL] count( distinct x )

2000-11-27 Thread Anthony
Kenn Thompson wrote: > What about > > select count(*) from (select distinct area from areapostcode where postcode like >'BS1%') > select count(*) from (select distinct area from areapostcode where postcode like 'BS1%'); ERROR: parser: parse error at or near "select" Thanks, any more ideas? >

Re: [SQL] count( distinct x )

2000-11-27 Thread Anthony
Michael Fork wrote: > I think you want > > SELECT count(distinct(area)) FROM areapostcode WHERE postcode LIKE 'BS1%' > psql still not happy :( SELECT count(distinct(area)) FROM areapostcode WHERE postcode LIKE 'BS1%'; ERROR: parser: parse error at or near "distinct" Thanks, Bap. > > Michael

Re: [SQL] count( distinct x )

2000-11-27 Thread Michael Fork
I think you want SELECT count(distinct(area)) FROM areapostcode WHERE postcode LIKE 'BS1%' Michael Fork - CCNA - MCP - A+ Network Support - Toledo Internet Access - Toledo Ohio On Mon, 27 Nov 2000, Anthony wrote: > Apologies if this has been asked b4, but got this result when > attemplting to

Re: [SQL] count( distinct x )

2000-11-27 Thread Anthony
Jose Rodrigo Fernandez Menegazzo wrote: > > The problem I have is with this statement: > > > > select count( distinct area ) from areapostcode where postcode like > > 'BS1%' > > > > the above statement fails with > > ERROR: parser: parse error at or near "distinct" > > > > I am not the g

Re: [SQL] count( distinct x )

2000-11-27 Thread Jose Rodrigo Fernandez Menegazzo
> The problem I have is with this statement: > > select count( distinct area ) from areapostcode where postcode like > 'BS1%' > > the above statement fails with > ERROR: parser: parse error at or near "distinct" > > I am not the greatest when it comes to SQL, but the pgsql docs implied >

[SQL] count( distinct x )

2000-11-27 Thread Anthony
Apologies if this has been asked b4, but got this result when attemplting to search the archives on the website Not Found The requested URL /mhonarc/pgsql-sql/search.cgi was not found on this server. Apache/1.3.12 Server at postgresql.rmplc.co.uk Port 80 The problem I have is with this statem

Re: [SQL] COUNT

2000-10-19 Thread bmccoy
On Fri, 20 Oct 2000, Craig May wrote: > How do I get a row count, like "Select [COUNT] from Table" ?? SELECT COUNT(*) FROM Brett W. McCoy http://www.chapelperilous.net --- Man

Re: [SQL] COUNT

2000-10-19 Thread Daniel Wickstrom
> "Brian" == Brian C Doyle <[EMAIL PROTECTED]> writes: Brian> Hello, You will need to do "SELECT count(attribute) FROM Brian> table;" or SELECT count(table.attribute);" You need to watch this: acspg=# create table tst ( acspg(# a integer acspg(# ); CREATE acspg=# insert into tst v

Re: [SQL] COUNT

2000-10-19 Thread Jie Liang
Hi, there, You want how many rows in your table??? select count(*) from yourtablename; Craig May wrote: > Hi, > > How do I get a row count, like "Select [COUNT] from Table" ?? > > Regards, > Craig May > > Enth Dimension > http://www.enthdimension.com.au -- Jie LIANG Internet Products Inc. 1

Re: [SQL] COUNT

2000-10-19 Thread Brian C. Doyle
Hello, You will need to do "SELECT count(attribute) FROM table;" or SELECT count(table.attribute);" At 04:58 AM 10/20/00 +, Craig May wrote: >Hi, > >How do I get a row count, like "Select [COUNT] from Table" ?? > >Regards, >Craig May > >Enth Dimension >http://www.enthdimension.com.au

Re: [SQL] COUNT

2000-10-19 Thread Frank Bax
Select count(*) from Table At 04:58 AM 10/20/00 +, Craig May wrote: >Hi, > >How do I get a row count, like "Select [COUNT] from Table" ?? > >Regards, >Craig May > >Enth Dimension >http://www.enthdimension.com.au > >

[SQL] COUNT

2000-10-19 Thread Craig May
Hi, How do I get a row count, like "Select [COUNT] from Table" ?? Regards, Craig May Enth Dimension http://www.enthdimension.com.au