I would use
SELECT id FROM table ORDER BY id LIMIT 0, 3;
in order to get the top 3 results. The key is "Limit" keyword.
==
Wei Weng
Network Software Engineer
KenCast Inc.
> -Original Message-
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED]]On Behalf Of Yoann
> Sent:
On Wednesday, 12. September 2001 11:06, Olle Wijk wrote:
> Hi,
>
> I am pretty new att using SQL-quires, could anyone help me with this
> one:
>
> I want to do the following SQL-query:
>
> Select XID, DENOM, PRICE, FRT, CTID From XItem xi, Category c Where
> xi.System=1 and xi.Category=c.Index
>
>
On 12 Sep 2001, Yoann wrote:
> OO( Sql Problem )Oo.
>
> That is to say a table of 5 inputs of 1 integer field :
>
>Table = { (1); (12); (3); (9); (4) }
Am I right that what you have is this?
CREATE TABLE T (v integer);
INSERT INTO T (v) VALUES (1);
INSERT INTO T (v) VALUES (12);
INSERT INTO
If you want "the third maximum value", easist to do:
SELECT * FROM table ORDER BY whatever DESC OFFSET 2 LIMIT 1;
- Original Message -
From: "Yoann" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, September 14, 2001 7:05 AM
Subject: Number the lines
> how can I number the res
Richard,
I'm curious now. What happens if you remove the table qualifications,
e.g.:
ORDER BY type, nom;
-Josh
__AGLIO DATABASE SOLUTIONS___
Josh Berkus
Complete information technology [EMAIL PROTECTED]
and data man
Mr. Nagy,
> Recently, I have upgraded my postgresql server from 7.0.2 to 7.1.3.
> But,
> now, one request which was 'good' before, don't want to work any more
> now.
I'm not sure I understand your question. What do you mean "doesn't
work"? Please give a detailed list of all steps taken, includi
What you want to know is probably this:
Select XID, xi.DENOM, PRICE, FRT, CTID From XItem xi, Category c Where
xi.System=1 and xi.Category=c.Index
Regards,
Patrik Kudo
---(end of broadcast)---
TIP 2: you can get off all lists at once with the un
Josh Berkus a écrit :
Mr. Nagy,
> Recently, I have upgraded my postgresql server from 7.0.2 to 7.1.3.
> But,
> now, one request which was 'good' before, don't want to work any
more
> now.
I'm not sure I understand your question. What do you mean "doesn't
work"? Please give a detailed list of all
Hi all
Is there any sample to show how to use array variable in PL/pgsql? How do I
get an array from a table and do a loop to manipulate every element in that
array?
jack
---(end of broadcast)---
TIP 5: Have you checked our extensive FAQ?
http:/
Hi all
Is there any sample to show how to use array variable in PL/pgsql? How do I
get an array from a table and do a loop to manipulate every element in that
array?
jack
---(end of broadcast)---
TIP 3: if posting/reading through Usenet, please
OO( Sql Problem )Oo.
That is to say a table of 5 inputs of 1 integer field :
Table = { (1); (12); (3); (9); (4) }
We want to obtain a result of 1 input of 3 fields,
corresponding to the 3 greatest values of Table,
by descending order :
Result = { (12; 9; 4) }
=> Which SQL query ma
I've compiled postgresql with multi-byte support, and created a
database with:
create database l1 with encoding 'LATIN1';
It was created succefull.
I started "psql l1" and issued this query "select upper('á')" and get
back "á" expected "Á".
I created a table with "create table test(f varchar(5
Hy Maik,
you can select it directly from the tables using following sql statement
(but it's same as using views):
select
t1.id, t1.f1, t2.f2
from
(select id, sum(amount) f1
from table1
group by id) t1,
(select id, sum(amount) f2
from table2
group by id) t2
where
t1.id = t2.id
but,
I don't get it? What's the difference between an inner-join and an
equijoin?
"Nils Zonneveld" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
>
>
> Maik wrote:
> >
> > Its clear, union concat the two results.
> >
> > But he can also use this join version, if its
You need to qualify "DENOM" with the table name: just write "xi.DENOM".
I find this to be good general practice when selecting from more than one
table.
- Original Message -
From: "Olle Wijk" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, September 12, 2001 4:06 AM
Subject:
[EMAIL PROTECTED] (Olle Wijk) wrote in message
news:<[EMAIL PROTECTED]>...
> Hi,
>
> I am pretty new att using SQL-quires, could anyone help me with this
> one:
>
> I want to do the following SQL-query:
>
> Select XID, DENOM, PRICE, FRT, CTID From XItem xi, Category c Where
> xi.System=1 and x
Can you post the exact errormessage?
- Original Message -
From: "Richard NAGY" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, September 14, 2001 12:11 PM
Subject: [SQL] SQL request change when upgrade from 7.0.2 to 7.1.3
> Hello,
>
> Recently, I have upgraded my postgresql
"Maik" <[EMAIL PROTECTED]> wrote in message
news:<9na15r$ku4$[EMAIL PROTECTED]>...
> Its clear, union concat the two results.
>
> But he can also use this join version, if its the intention.
>
> select t1.id, sum(t1.amount), t2.id, sum(t2.amount) from table1 as t1,
> table2 as t2 where t1.id=t2
Hi all
Is there any sample to show how to use array variable in PL/pgsql? How do I
get an array from a table and do a loop to manipulate every element in that
array?
jack
---(end of broadcast)---
TIP 5: Have you checked our extensive FAQ?
http:
Hi,
I have to query many tables (about 18 tables)
from a database to field a riport in HTML.
I can make the query and it works (I think), but it's a bit strange to
me.
The query looks like this:
select * from table1 f, table2 s, table3 t, table4 fo, table5 fi,
table6 si, table 7 se, table8 e, t
Is there any sample to show how to use array variable in PL/pgsql? How do I
get an array from a table and do a loop to manipulate every element in that
array?
jack
---(end of broadcast)---
TIP 2: you can get off all lists at once with the unregi
Hi,
I am pretty new att using SQL-quires, could anyone help me with this
one:
I want to do the following SQL-query:
Select XID, DENOM, PRICE, FRT, CTID From XItem xi, Category c Where
xi.System=1 and xi.Category=c.Index
the problem is that the field 'DENOM' is present in both table 'XItem'
and
Maik wrote:
>
> Its clear, union concat the two results.
>
> But he can also use this join version, if its the intention.
>
> select t1.id, sum(t1.amount), t2.id, sum(t2.amount) from table1 as t1,
> table2 as t2 where t1.id=t2.id;
>
Yeps, thats another way to write an inner join :-)
Mazzel
Hi ,
I read one of solution to andreas problem of how to set autocommit off but
my problem still persists. I am basically writing a function in plpgsql
language which performs a number of update and insert statements but on a
failing condition it rollbacks inorder to maintain integrity in the
d
Maik wrote:
>
> With "Union" you can create one view.
> Ciao Maik
UNION wouldn't have the desired effect:
the result of a UNION SELECT would look like this:
ID AMOUNT
1 (table1.amount)
2 (table1.amount)
. .
. .
1 (table2.amount)
2 (table2.amount)
What he wants is:
ID TABLE1.AMOUNT
how can I number the result's lines of a sql query ?
explaination : I have a query which return me a list of values. I need
to order them (it's ok, easy ;) and then number the lines. The goal is
then to extract, for example, "the third maximum value".
Tx in advance !
Yoann
-
Its clear, union concat the two results.
But he can also use this join version, if its the intention.
select t1.id, sum(t1.amount), t2.id, sum(t2.amount) from table1 as t1,
table2 as t2 where t1.id=t2.id;
Ciao Maik
---(end of broadcast)---
TIP
Bhuvan A writes:
> SELECT EXTRACT(EPOCH FROM TIMESTAMP(now()));
> date_part
>
> 1000467997
> (1 row)
>
> Fine..
>
> Similarly, how could i get timestamp value for these SECONDS?
TIMESTAMP 'epoch' + INTERVAL 'N seconds'
--
Peter Eisentraut [EMAIL PROTECTED] http://funkturm.ho
Hi all,
Consider this..
SELECT EXTRACT(EPOCH FROM TIMESTAMP(now()));
date_part
1000467997
(1 row)
Fine..
Similarly, how could i get timestamp value for SECONDS?
ie.. VICE VERSA
Something like this..
:)
select extract(timestamp from interval('1000467997 seconds'));
:)
Ki
Hi all,
Consider this..
SELECT EXTRACT(EPOCH FROM TIMESTAMP(now()));
date_part
1000467997
(1 row)
Fine..
Similarly, how could i get timestamp value for these SECONDS?
ie.. VICE VERSA
Something like this..
SELECT EXTRACT(TIMESTAMP FROM INTERVAL('1000467997 SECONDS'));
:)
K
Hello,
Recently, I have upgraded my postgresql server from 7.0.2 to 7.1.3.
But, now, one request which was 'good' before, don't want to work any more
now.
It was : (pretty long)
SELECT aes.ent_id, e.type, e.nom, aes.sect_id as voulu,
cvd_new(current_date, e.date_entree, 'new') FROM ass_entrep_sec
31 matches
Mail list logo