From: | "Oliver Elphick" <olly(at)lfix(dot)co(dot)uk> |
---|---|
To: | Uros Gruber <uros(at)sir-mag(dot)com> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: Trouble with JOINS |
Date: | 2001-04-05 15:58:18 |
Message-ID: | 200104051558.f35FwIa29155@linda.lfix.co.uk |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Uros Gruber wrote:
>Hi!
>
>I have some stupid problem wich is driving me nuts.
>
>This is my 2 tables.
>
>CREATE TABLE one ( one_id varchar(23)
> day varchar(10),
> view int4,
> two_id varchar(32),
> PRIMARY KEY (one_id)
>);
>
>CREATE TABLE two ( tow_id varchar(32),
> user varchar(12) NOT NULL,
> PRIMARY KEY (client_id)
>);
>
>table one is tracking views of some user, and table two is actual data
>of that user.
>
>What i want to get from SQL is something like this
>
>user view
>u1 34
>u2 14
>u3 8
>
>The data in tabel are like this
>two_id day view one_id
>aaa 1 15 1
>bbb 1 7 2
>ccc 2 2 3
>bbb 2 7 4
>aaa 3 19 5
>ccc 3 6 6
>
>
>two_id user
>aaa u1
>bbb u2
>ccc u3
>
>I hope you'll understand what i want to do. If not tell me.
SELECT user, sum(view)
FROM one, two
WHERE one.two_id = two.two_id
GROUP BY user;
--
Oliver Elphick Oliver(dot)Elphick(at)lfix(dot)co(dot)uk
Isle of Wight http://www.lfix.co.uk/oliver
PGP: 1024R/32B8FAA1: 97 EA 1D 47 72 3F 28 47 6B 7E 39 CC 56 E4 C1 47
GPG: 1024D/3E1D0C1C: CA12 09E0 E8D5 8870 5839 932A 614D 4C34 3E1D 0C1C
========================================
"My dear brothers, take note of this: Everyone should
be quick to listen, slow to speak and slow to become
angry, for man's anger does not bring about the
righteous life that God desires." James 1:19,20
From | Date | Subject | |
---|---|---|---|
Next Message | Richard Huxton | 2001-04-05 16:01:32 | Re: Data transfer format between UNIX server and Windows client? |
Previous Message | Keith G. Murphy | 2001-04-05 15:53:51 | Re: Data transfer format between UNIX server and Windows client? |