pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedSQL
20+ messages / 17 participants
[nested] [flat]
* SQL
@ 2000-07-12 17:11 DATAPUC-Frederico Papatella Guerino <papatella@pucminas.br>
0 siblings, 0 replies; 20+ messages in thread
From: DATAPUC-Frederico Papatella Guerino @ 2000-07-12 17:11 UTC (permalink / raw)
To: pgsql-sql
Hi,
I'd like an information about the history of SQL.
The similarities and differences between SQL1 and SQL2 and SQL3.
Thank you,
Frederico Papatella Guerino
Belo Horizonte-MG/ Brasil
papatella@pucminas.br
^ permalink raw reply [nested|flat] 20+ messages in thread
* Re: SQL
@ 2000-10-23 19:04 Josh Berkus <josh@agliodbs.com>
0 siblings, 0 replies; 20+ messages in thread
From: Josh Berkus @ 2000-10-23 19:04 UTC (permalink / raw)
To: pgsql-sql
(Aplolgies to Mr. McCoy, to whom I mailed this awnser in error)
Mr. Bajerski,
> > I've got answer from Postgres
> > "Illegal attributes or non-group column"
> >
> > Is it error in query or in parser ?
It's your query. In a GROUP BY query, all named columns must either
contain and aggregate function (e.g. SUM) or be named in the GROUP BY
clause.
O'Reilly has just come out with a SQL in a Nutshell book. I'd suggest
picking one up.
-Josh Berkus
--
______AGLIO DATABASE SOLUTIONS___________________________
Josh Berkus
Complete information technology josh@agliodbs.com
and data management solutions (415) 436-9166
for law firms, small businesses fax 436-0137
and non-profit organizations. pager 338-4078
San Francisco
^ permalink raw reply [nested|flat] 20+ messages in thread
* Sql
@ 2001-08-26 00:55 Marcia Cunha <malves.bh@terra.com.br>
2001-08-30 22:53 ` Re: Sql Bruce Momjian <pgman@candle.pha.pa.us>
0 siblings, 1 reply; 20+ messages in thread
From: Marcia Cunha @ 2001-08-26 00:55 UTC (permalink / raw)
To: pgsql-sql
Hi,
I'd like an information about the history of SQL.
The similarities and differences between SQL1 and SQL2 and SQL3.
Could you help me?
Thanks for your attention.
Marcia Cunha
Belo Horizonte , Brasil.
^ permalink raw reply [nested|flat] 20+ messages in thread
* Re: Sql
2001-08-26 00:55 Sql Marcia Cunha <malves.bh@terra.com.br>
@ 2001-08-30 22:53 ` Bruce Momjian <pgman@candle.pha.pa.us>
0 siblings, 0 replies; 20+ messages in thread
From: Bruce Momjian @ 2001-08-30 22:53 UTC (permalink / raw)
To: Marcia Cunha <malves.bh@terra.com.br>; +Cc: pgsql-sql
For history, see the first chapter of my book. Also see appendix on
non-standard feature.
http://www.postgresql.org/docs/awbook.html
> Hi,
>
> I'd like an information about the history of SQL.
> The similarities and differences between SQL1 and SQL2 and SQL3.
>
> Could you help me?
>
> Thanks for your attention.
>
> Marcia Cunha
> Belo Horizonte , Brasil.
>
--
Bruce Momjian | http://candle.pha.pa.us
pgman@candle.pha.pa.us | (610) 853-3000
+ If your life is a hard drive, | 830 Blythe Avenue
+ Christ can be your backup. | Drexel Hill, Pennsylvania 19026
^ permalink raw reply [nested|flat] 20+ messages in thread
* SQL
@ 2001-11-16 11:19 Andriy Pyrozhenko <andriy.pyrozhenko@vanjaonline.com>
0 siblings, 0 replies; 20+ messages in thread
From: Andriy Pyrozhenko @ 2001-11-16 11:19 UTC (permalink / raw)
To: pgsql-sql
Hello ,
I have the rule for table
CREATE RULE del_jobs_del_activity AS ON DELETE TO jobs DO DELETE FROM activities WHERE job_id = OLD.job_id;
When i call:
DELETE FROM jobs WHERE job_id IN (SELECT DISTINCT job_id FROM
activities WHERE load_no = 123)
This query does not delete the record from jobs but delete the
record by rule.
What must I change for work this query correctly?
Best regards,
Andriy mailto:andriy.pyrozhenko@vanjaonline.com
^ permalink raw reply [nested|flat] 20+ messages in thread
* sql
@ 2002-12-09 10:40 cristi <cristi@dmhi.ct.ro>
2002-12-09 12:04 ` Re: sql Richard Huxton <dev@archonet.com>
0 siblings, 1 reply; 20+ messages in thread
From: cristi @ 2002-12-09 10:40 UTC (permalink / raw)
To: pgsql-sql
I have 3 tables.
table_a
marca
15145
1455
1333
table_b
data
11-01-2002
11-02-2002
table_c
marca data
15145 11-01-2002
15145 11-02-2002
1455 11-01-2002
1333 11-01-2002
1333 11-02-2002
After interogation of the tables I need this kind of result:
marca data
1455 11-02-2002
(I want to receive the records which are a combitation of fields of table_a and table_b and that are not in the table_c)
How can I do that?
Thanks!
^ permalink raw reply [nested|flat] 20+ messages in thread
* Re: sql
2002-12-09 10:40 sql cristi <cristi@dmhi.ct.ro>
@ 2002-12-09 12:04 ` Richard Huxton <dev@archonet.com>
0 siblings, 0 replies; 20+ messages in thread
From: Richard Huxton @ 2002-12-09 12:04 UTC (permalink / raw)
To: cristi <cristi@dmhi.ct.ro>; pgsql-sql
On Monday 09 Dec 2002 10:40 am, cristi wrote:
> (I want to receive the records which are a combitation of fields of table_a
> and table_b and that are not in the table_c)
The following is one way. Not necessarily the most efficient, but it should be
clear enough. Basically it builds the product of table_a,table_b then uses a
LEFT JOIN with WHERE to find items that don't match.
You'll want to test it against your real data to see if it's fast enough.
richardh=> SELECT * FROM table_a;
a
---
1
2
3
(3 rows)
richardh=> SELECT * FROM table_b;
b
------------
2002-01-01
2002-02-02
2002-03-03
(3 rows)
richardh=> SELECT * FROM table_c;
ca | cb
----+------------
1 | 2002-01-01
1 | 2002-02-02
2 | 2002-02-02
(3 rows)
richardh=> \d view_ab
View "view_ab"
Column | Type | Modifiers
--------+---------+-----------
a | integer |
b | date |
View definition: SELECT table_a.a, table_b.b FROM table_a, table_b;
richardh=> SELECT a,b FROM view_ab LEFT JOIN table_c ON a=ca AND b=cb WHERE ca
IS NULL or cb IS NULL ORDER BY a,b;
a | b
---+------------
1 | 2002-03-03
2 | 2002-01-01
2 | 2002-03-03
3 | 2002-01-01
3 | 2002-02-02
3 | 2002-03-03
(6 rows)
--
Richard Huxton
^ permalink raw reply [nested|flat] 20+ messages in thread
* SQL
@ 2003-03-19 20:52 Sethi Tarun-ETS017 <Tarun.Sethi@motorola.com>
0 siblings, 0 replies; 20+ messages in thread
From: Sethi Tarun-ETS017 @ 2003-03-19 20:52 UTC (permalink / raw)
To: pgsql-sql
In SQL, how can I remove the newline characters from the value of a column?
^ permalink raw reply [nested|flat] 20+ messages in thread
* SQL
@ 2003-07-02 06:21 Jonathan Man <jman@equityunderwriters.com.hk>
0 siblings, 0 replies; 20+ messages in thread
From: Jonathan Man @ 2003-07-02 06:21 UTC (permalink / raw)
To: pgsql-sql
Dear All,
May I execute a SQL to find out user's information (e.g. user id or ip address) who are connecting to a database?
THX!!
JMAN
^ permalink raw reply [nested|flat] 20+ messages in thread
* sql
@ 2004-06-23 10:43 cristi <cristi@dmhi.ct.ro>
2004-06-23 11:38 ` Re: sql Richard Huxton <dev@archonet.com>
0 siblings, 1 reply; 20+ messages in thread
From: cristi @ 2004-06-23 10:43 UTC (permalink / raw)
To: pgsql-sql
I have the following table structure:
CREATE TABLE "xxx" (
"co" character varying(7),
"co1" character varying(9),
"n1" character varying(15),
"l1" character varying(5),
"m1" smallint,
"ore" bigint
);
who contains the following date:
22021CC 1044 637 S5G8 407 5
22021CC 1044 637 S5G8 409 47
22021CD 1044 637 S5G8 410 24
22022BB 1044 637 S5G8 409 10
I need a SQL select which result to be:
22021CC 1044 637 S5G8 407 5
22021CC 1044 637 S5G8 409 57
22021CD 1044 637 S5G8 410 24
I mean:
I want to select the records wich for co1,n1,l1,m1 value are the same and
has the maxim value of the ore field
adding to that value the value of the records which are not selected.
Wou!
Thanks in advance!
^ permalink raw reply [nested|flat] 20+ messages in thread
* Re: sql
2004-06-23 10:43 sql cristi <cristi@dmhi.ct.ro>
@ 2004-06-23 11:38 ` Richard Huxton <dev@archonet.com>
0 siblings, 0 replies; 20+ messages in thread
From: Richard Huxton @ 2004-06-23 11:38 UTC (permalink / raw)
To: cristi <cristi@dmhi.ct.ro>; +Cc: pgsql-sql
cristi wrote:
>
> I mean:
> I want to select the records wich for co1,n1,l1,m1 value are the same and
> has the maxim value of the ore field
> adding to that value the value of the records which are not selected.
SELECT co,clo1,nl,l1,m1,SUM(ore) AS tot_ore
FROM xxx
WHERE <conditions here>
GROUP BY co,clo1,nl,l1,m1
ORDER BY co,clo1,nl,l1,m1;
--
Richard Huxton
Archonet Ltd
^ permalink raw reply [nested|flat] 20+ messages in thread
* sql
@ 2004-10-25 08:13 cristivoinicaru <cristivoinicaru@dmhi.ct.ro>
2004-10-25 10:04 ` Re: sql Andrei Bintintan <klodoma@ar-sd.net>
2004-10-25 11:20 ` Re: sql Mike Rylander <mrylander@gmail.com>
0 siblings, 2 replies; 20+ messages in thread
From: cristivoinicaru @ 2004-10-25 08:13 UTC (permalink / raw)
To: pgsql-sql
I have a postgres table like this:
CREATE TABLE "temp50" (
"gc" character varying(36),
"co" character varying(7),
"data" date,
"ora" smallint
);
It contains the following records:
5003707G9G9419 22012BB 10-14-2004 82
5003707G9G9419 22012BC 10-14-2004 44
5003707G9G9419 22022BB 10-14-2004 82
5003707G9G9420 22022BC 10-18-2004 49
I'd like the result of the sql interogation to be like this:
5003707G9G9419 22012BB 10-14-2004 82
5003707G9G9420 22022BC 10-18-2004 49
Explanations:
I want like sql interogation to select only one record from each "gc" group
record (who has the same code "gc" (that means that the "gc" field will be
unique key)) with the following two condition:
1)from each "gc" group of records to select the record who has the value of
"ora" field maxim.
2)if two ore more record have the same value of the maxim value of the "ora"
to select oly one of them
Thanks!
^ permalink raw reply [nested|flat] 20+ messages in thread
* Re: sql
2004-10-25 08:13 sql cristivoinicaru <cristivoinicaru@dmhi.ct.ro>
@ 2004-10-25 10:04 ` Andrei Bintintan <klodoma@ar-sd.net>
1 sibling, 0 replies; 20+ messages in thread
From: Andrei Bintintan @ 2004-10-25 10:04 UTC (permalink / raw)
To: cristivoinicaru <cristivoinicaru@dmhi.ct.ro>; pgsql-sql
> 2)if two ore more record have the same value of the maxim value of the
"ora"
> to select oly one of them
At this point you really have to decide which criteria you use for this
deciding.
I strongly suggest to use a uniqe ID for each row in the table(in your case
it is important):
CREATE TABLE "temp50" (
id serial primary key,
"gc" character varying(36),
"co" character varying(7),
"data" date,
"ora" smallint
);
Your selection can be made in many ways, but you have to decide the second
criteria.
One more thing:
Your table datas are:
1 >> 5003707G9G9419 22012BB 10-14-2004 82
2 >> 5003707G9G9419 22012BC 10-14-2004 44
3 >> 5003707G9G9419 22022BB 10-14-2004 82
4 >> 5003707G9G9420 22022BC 10-18-2004 49
The rows no 1 and 3 are "redundant" data's(they are the same). Do you really
want this???
Best regards,
Andy.
----- Original Message -----
From: "cristivoinicaru" <cristivoinicaru@dmhi.ct.ro>
To: <pgsql-sql@postgresql.org>
Sent: Monday, October 25, 2004 11:13 AM
Subject: [SQL] sql
> I have a postgres table like this:
>
> CREATE TABLE "temp50" (
> "gc" character varying(36),
> "co" character varying(7),
> "data" date,
> "ora" smallint
>
> );
>
> It contains the following records:
>
> 5003707G9G9419 22012BB 10-14-2004 82
> 5003707G9G9419 22012BC 10-14-2004 44
> 5003707G9G9419 22022BB 10-14-2004 82
> 5003707G9G9420 22022BC 10-18-2004 49
>
> I'd like the result of the sql interogation to be like this:
>
> 5003707G9G9419 22012BB 10-14-2004 82
> 5003707G9G9420 22022BC 10-18-2004 49
>
>
> Explanations:
> I want like sql interogation to select only one record from each "gc"
group
> record (who has the same code "gc" (that means that the "gc" field will be
> unique key)) with the following two condition:
> 1)from each "gc" group of records to select the record who has the value
of
> "ora" field maxim.
> 2)if two ore more record have the same value of the maxim value of the
"ora"
> to select oly one of them
>
> Thanks!
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 8: explain analyze is your friend
>
^ permalink raw reply [nested|flat] 20+ messages in thread
* Re: sql
2004-10-25 08:13 sql cristivoinicaru <cristivoinicaru@dmhi.ct.ro>
@ 2004-10-25 11:20 ` Mike Rylander <mrylander@gmail.com>
2004-10-25 11:44 ` Re: sql Andrew J. Kopciuch <akopciuch@bddf.ca>
1 sibling, 1 reply; 20+ messages in thread
From: Mike Rylander @ 2004-10-25 11:20 UTC (permalink / raw)
To: cristivoinicaru <cristivoinicaru@dmhi.ct.ro>; +Cc: pgsql-sql
On Mon, 25 Oct 2004 10:13:37 +0200, cristivoinicaru
<cristivoinicaru@dmhi.ct.ro> wrote:
> I have a postgres table like this:
>
> CREATE TABLE "temp50" (
> "gc" character varying(36),
> "co" character varying(7),
> "data" date,
> "ora" smallint
>
> );
>
> It contains the following records:
>
> 5003707G9G9419 22012BB 10-14-2004 82
> 5003707G9G9419 22012BC 10-14-2004 44
> 5003707G9G9419 22022BB 10-14-2004 82
> 5003707G9G9420 22022BC 10-18-2004 49
>
> I'd like the result of the sql interogation to be like this:
>
> 5003707G9G9419 22012BB 10-14-2004 82
> 5003707G9G9420 22022BC 10-18-2004 49
>
> Explanations:
> I want like sql interogation to select only one record from each "gc" group
> record (who has the same code "gc" (that means that the "gc" field will be
> unique key)) with the following two condition:
> 1)from each "gc" group of records to select the record who has the value of
> "ora" field maxim.
> 2)if two ore more record have the same value of the maxim value of the "ora"
> to select oly one of them
Try:
SELECT * FROM temp50 GROUP BY gc ORDER BY ora DESC;
--miker
>
> Thanks!
>
> ---------------------------(end of broadcast)---------------------------
> TIP 8: explain analyze is your friend
>
^ permalink raw reply [nested|flat] 20+ messages in thread
* Re: sql
2004-10-25 08:13 sql cristivoinicaru <cristivoinicaru@dmhi.ct.ro>
2004-10-25 11:20 ` Re: sql Mike Rylander <mrylander@gmail.com>
@ 2004-10-25 11:44 ` Andrew J. Kopciuch <akopciuch@bddf.ca>
2004-10-25 13:05 ` Re: sql Mike Rylander <mrylander@gmail.com>
0 siblings, 1 reply; 20+ messages in thread
From: Andrew J. Kopciuch @ 2004-10-25 11:44 UTC (permalink / raw)
To: Mike Rylander <mrylander@gmail.com>; +Cc: pgsql-sql
On Monday 25 October 2004 05:20, Mike Rylander wrote:
> SELECT * FROM temp50 GROUP BY gc ORDER BY ora DESC;
You can not have have expressions (columns etc.) in the SELECT list that are
either not in a GROUP BY clause, or used in an aggregate function when you
use GROUP BY in the statement. By saying SELECT *, means you would have to
GROUP BY gc, co, data, ora ...
That isn't going to do what he wants. And the SQL you stated should give you
an error:
ERROR: column "temp50.co" must appear in the GROUP BY clause or be used in an
aggregate function
What he wants to do is use DISTINCT ON:
SELECT DISTINCT ON (gc) gc, co, data, ora FROM temp50 ORDER BY gc, ora DESC;
Andy
^ permalink raw reply [nested|flat] 20+ messages in thread
* Re: sql
2004-10-25 08:13 sql cristivoinicaru <cristivoinicaru@dmhi.ct.ro>
2004-10-25 11:20 ` Re: sql Mike Rylander <mrylander@gmail.com>
2004-10-25 11:44 ` Re: sql Andrew J. Kopciuch <akopciuch@bddf.ca>
@ 2004-10-25 13:05 ` Mike Rylander <mrylander@gmail.com>
0 siblings, 0 replies; 20+ messages in thread
From: Mike Rylander @ 2004-10-25 13:05 UTC (permalink / raw)
To: akopciuch@bddf.ca; +Cc: pgsql-sql
On Mon, 25 Oct 2004 05:44:06 -0600, Andrew J. Kopciuch
<akopciuch@bddf.ca> wrote:
> On Monday 25 October 2004 05:20, Mike Rylander wrote:
> > SELECT * FROM temp50 GROUP BY gc ORDER BY ora DESC;
>
> You can not have have expressions (columns etc.) in the SELECT list that are
> either not in a GROUP BY clause, or used in an aggregate function when you
> use GROUP BY in the statement. By saying SELECT *, means you would have to
> GROUP BY gc, co, data, ora ...
Doh! Of course. Should have had coffee before writing that ;)
>
> That isn't going to do what he wants. And the SQL you stated should give you
> an error:
>
> ERROR: column "temp50.co" must appear in the GROUP BY clause or be used in an
> aggregate function
>
> What he wants to do is use DISTINCT ON:
>
> SELECT DISTINCT ON (gc) gc, co, data, ora FROM temp50 ORDER BY gc, ora DESC;
>
> Andy
>
^ permalink raw reply [nested|flat] 20+ messages in thread
* sql
@ 2007-02-02 07:39 Shyju Narayanan <shyjukoyyam@gmail.com>
2007-02-06 06:41 ` Re: sql A. Kretschmer <andreas.kretschmer@schollglas.com>
2007-02-06 07:16 ` Re: sql Karthikeyan Sundaram <skarthi98@hotmail.com>
0 siblings, 2 replies; 20+ messages in thread
From: Shyju Narayanan @ 2007-02-02 07:39 UTC (permalink / raw)
To: pgsql-sql
Hi All
this is my table ;
| ID |entry_user_id_int | category_id_chv |
----------------------------------------------
| 1 | 78 | CV |
----------------------------------------------
| 2 | 78 | VC |
----------------------------------------------
| 3 | 78 | CV |
----------------------------------------------
| 4 | 78 | CV |
----------------------------------------------
| 5 | 78 | CV |
----------------------------------------------
| 6 | 78 | CV |
----------------------------------------------
| 7 | 78 | CV |
----------------------------------------------
| 8 | 78 | CV |
----------------------------------------------
| 9 | 78 | VE |
----------------------------------------------
| 10 | 78 | CV |
----------------------------------------------
| 11 | 78 | SC |
----------------------------------------------
WHEN "select entry_user_id_int, category_id_chv,count(category_id_chv) from
vigilance_master group by category_id_chv,entry_user_id_int having"
entry_user_id_int=78
result is :
ID entry_user_id_int category_id_chv count
1 78 VC 1
2 78 VE 1
3 78 CV 8
4 78 SC 1
BUT I NEED THE RESULT AS
entry_user_id_int COUNT(VC) COUNT(VE) COUNT(CV) COUNT(SC) TOTAL
78 1 1 8 1 11
^ permalink raw reply [nested|flat] 20+ messages in thread
* Re: sql
2007-02-02 07:39 sql Shyju Narayanan <shyjukoyyam@gmail.com>
@ 2007-02-06 06:41 ` A. Kretschmer <andreas.kretschmer@schollglas.com>
1 sibling, 0 replies; 20+ messages in thread
From: A. Kretschmer @ 2007-02-06 06:41 UTC (permalink / raw)
To: pgsql-sql
am Fri, dem 02.02.2007, um 13:09:09 +0530 mailte Shyju Narayanan folgendes:
> Hi All
>
>
> BUT I NEED THE RESULT AS
> entry_user_id_int COUNT(VC) COUNT(VE) COUNT(CV) COUNT(SC) TOTAL
> 78 1 1 8 1 11
>
You need something like this (i called the table foo and without the
sc-column):
select entry_user_id_int,
sum(case when category_id_chv = 'VC' then 1 else 0 end) as "count(vc)",
sum(case when category_id_chv = 'VE' then 1 else 0 end),
sum(case when category_id_chv = 'CV' then 1 else 0 end),
sum(1)
from foo
where entry_user_id_int = 78
group by entry_user_id_int;
entry_user_id_int | count(vc) | sum | sum | sum
-------------------+-----------+-----+-----+-----
78 | 1 | 1 | 8 | 11
Andreas
--
Andreas Kretschmer
Kontakt: Heynitz: 035242/47150, D1: 0160/7141639 (mehr: -> Header)
GnuPG-ID: 0x3FFF606C, privat 0x7F4584DA http://wwwkeys.de.pgp.net
^ permalink raw reply [nested|flat] 20+ messages in thread
* Re: sql
2007-02-02 07:39 sql Shyju Narayanan <shyjukoyyam@gmail.com>
@ 2007-02-06 07:16 ` Karthikeyan Sundaram <skarthi98@hotmail.com>
1 sibling, 0 replies; 20+ messages in thread
From: Karthikeyan Sundaram @ 2007-02-06 07:16 UTC (permalink / raw)
To: shyjukoyyam@gmail.com; pgsql-sql
try this:
select entry_user_id, sum(decode(entry_user_id,'VC',1,0) as vc,
sum(decode(entry_user_id,'VE',1,0) as ve,
sum(decode(entry_user_id,'CV',1,0) as cv,
sum(decode(entry_user_id,'SC',1,0) as SC
from vigilance_master group
where entry_user_id=78
group by entry_user_id
>From: "Shyju Narayanan" <shyjukoyyam@gmail.com>
>To: pgsql-sql@postgresql.org
>Subject: [SQL] sql
>Date: Fri, 2 Feb 2007 13:09:09 +0530
>
>Hi All
>
>this is my table ;
>| ID |entry_user_id_int | category_id_chv |
>----------------------------------------------
>| 1 | 78 | CV |
>----------------------------------------------
>| 2 | 78 | VC |
>----------------------------------------------
>| 3 | 78 | CV |
>----------------------------------------------
>| 4 | 78 | CV |
>----------------------------------------------
>| 5 | 78 | CV |
>----------------------------------------------
>| 6 | 78 | CV |
>----------------------------------------------
>| 7 | 78 | CV |
>----------------------------------------------
>| 8 | 78 | CV |
>----------------------------------------------
>| 9 | 78 | VE |
>----------------------------------------------
>| 10 | 78 | CV |
>----------------------------------------------
>| 11 | 78 | SC |
>----------------------------------------------
>
>WHEN "select entry_user_id_int, category_id_chv,count(category_id_chv) from
>vigilance_master group by category_id_chv,entry_user_id_int having"
>entry_user_id_int=78
>result is :
>
>ID entry_user_id_int category_id_chv count
>
>1 78 VC 1
>2 78 VE 1
>3 78 CV 8
>4 78 SC 1
>
>BUT I NEED THE RESULT AS
>entry_user_id_int COUNT(VC) COUNT(VE) COUNT(CV) COUNT(SC) TOTAL
>78 1 1 8 1 11
_________________________________________________________________
Get in the mood for Valentine's Day. View photos, recipes and more on your
Live.com page.
http://www.live.com/?addTemplate=ValentinesDay&ocid=T001MSN30A0701
^ permalink raw reply [nested|flat] 20+ messages in thread
* Re: sql
@ 2007-02-06 08:41 Penchalaiah P. <penchalaiahp@infics.com>
0 siblings, 0 replies; 20+ messages in thread
From: Penchalaiah P. @ 2007-02-06 08:41 UTC (permalink / raw)
To: Karthikeyan Sundaram <skarthi98@hotmail.com>; shyjukoyyam@gmail.com; pgsql-sql
Hi...
I tried this its working.. can u please check this.
select count(*) as all, sum(decode(entry_user_id,'VC',1)) as
entry_user_id,sum(decode(entry_user_id,'VE',1)) as VE
,sum(decode(entry_user_id,CV,1))as
CV,sum(decode(entry_user_id,'SC',1))as SC from vigilance_master;
regards
penchal
-----Original Message-----
From: pgsql-sql-owner@postgresql.org
[mailto:pgsql-sql-owner@postgresql.org] On Behalf Of Karthikeyan
Sundaram
Sent: Tuesday, February 06, 2007 12:47 PM
To: shyjukoyyam@gmail.com; pgsql-sql@postgresql.org
Subject: Re: [SQL] sql
try this:
select entry_user_id, sum(decode(entry_user_id,'VC',1,0) as vc,
sum(decode(entry_user_id,'VE',1,0) as ve,
sum(decode(entry_user_id,'CV',1,0) as cv,
sum(decode(entry_user_id,'SC',1,0) as SC
from vigilance_master group
where entry_user_id=78
group by entry_user_id
>From: "Shyju Narayanan" <shyjukoyyam@gmail.com>
>To: pgsql-sql@postgresql.org
>Subject: [SQL] sql
>Date: Fri, 2 Feb 2007 13:09:09 +0530
>
>Hi All
>
>this is my table ;
>| ID |entry_user_id_int | category_id_chv |
>----------------------------------------------
>| 1 | 78 | CV |
>----------------------------------------------
>| 2 | 78 | VC |
>----------------------------------------------
>| 3 | 78 | CV |
>----------------------------------------------
>| 4 | 78 | CV |
>----------------------------------------------
>| 5 | 78 | CV |
>----------------------------------------------
>| 6 | 78 | CV |
>----------------------------------------------
>| 7 | 78 | CV |
>----------------------------------------------
>| 8 | 78 | CV |
>----------------------------------------------
>| 9 | 78 | VE |
>----------------------------------------------
>| 10 | 78 | CV |
>----------------------------------------------
>| 11 | 78 | SC |
>----------------------------------------------
>
>WHEN "select entry_user_id_int, category_id_chv,count(category_id_chv)
from
>vigilance_master group by category_id_chv,entry_user_id_int having"
>entry_user_id_int=78
>result is :
>
>ID entry_user_id_int category_id_chv count
>
>1 78 VC 1
>2 78 VE 1
>3 78 CV 8
>4 78 SC 1
>
>BUT I NEED THE RESULT AS
>entry_user_id_int COUNT(VC) COUNT(VE) COUNT(CV) COUNT(SC)
TOTAL
>78 1 1 8 1 11
_________________________________________________________________
Get in the mood for Valentine's Day. View photos, recipes and more on
your
Live.com page.
http://www.live.com/?addTemplate=ValentinesDay&ocid=T001MSN30A0701
---------------------------(end of broadcast)---------------------------
TIP 4: Have you searched our list archives?
http://archives.postgresql.org
Information transmitted by this e-mail is proprietary to Infinite Computer Solutions and / or its Customers and is intended for use only by the individual or the entity to which it is addressed, and may contain information that is privileged, confidential or exempt from disclosure under applicable law. If you are not the intended recipient or it appears that this mail has been forwarded to you without proper authority, you are notified that any use or dissemination of this information in any manner is strictly prohibited. In such cases, please notify us immediately at info.in@infics.com and delete this email from your records.
^ permalink raw reply [nested|flat] 20+ messages in thread
end of thread, other threads:[~2007-02-06 08:41 UTC | newest]
Thread overview: 20+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2000-07-12 17:11 SQL DATAPUC-Frederico Papatella Guerino <papatella@pucminas.br>
2000-10-23 19:04 Re: SQL Josh Berkus <josh@agliodbs.com>
2001-08-26 00:55 Sql Marcia Cunha <malves.bh@terra.com.br>
2001-08-30 22:53 ` Re: Sql Bruce Momjian <pgman@candle.pha.pa.us>
2001-11-16 11:19 SQL Andriy Pyrozhenko <andriy.pyrozhenko@vanjaonline.com>
2002-12-09 10:40 sql cristi <cristi@dmhi.ct.ro>
2002-12-09 12:04 ` Re: sql Richard Huxton <dev@archonet.com>
2003-03-19 20:52 SQL Sethi Tarun-ETS017 <Tarun.Sethi@motorola.com>
2003-07-02 06:21 SQL Jonathan Man <jman@equityunderwriters.com.hk>
2004-06-23 10:43 sql cristi <cristi@dmhi.ct.ro>
2004-06-23 11:38 ` Re: sql Richard Huxton <dev@archonet.com>
2004-10-25 08:13 sql cristivoinicaru <cristivoinicaru@dmhi.ct.ro>
2004-10-25 10:04 ` Re: sql Andrei Bintintan <klodoma@ar-sd.net>
2004-10-25 11:20 ` Re: sql Mike Rylander <mrylander@gmail.com>
2004-10-25 11:44 ` Re: sql Andrew J. Kopciuch <akopciuch@bddf.ca>
2004-10-25 13:05 ` Re: sql Mike Rylander <mrylander@gmail.com>
2007-02-02 07:39 sql Shyju Narayanan <shyjukoyyam@gmail.com>
2007-02-06 06:41 ` Re: sql A. Kretschmer <andreas.kretschmer@schollglas.com>
2007-02-06 07:16 ` Re: sql Karthikeyan Sundaram <skarthi98@hotmail.com>
2007-02-06 08:41 Re: sql Penchalaiah P. <penchalaiahp@infics.com>
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