[SQL] SQL request change when upgrade from 7.0.2 to 7.1.3
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_sectact aes, entreprise e WHERE e.id = aes.ent_id and aes.sect_id <> 3 and aes.sect_id <> 9 and aes.sect_id <> 1 and aes.sect_id <> 13 and aes.sect_id = 56 UNION SELECT distinct on (aes.ent_id) aes.ent_id, e.type, e.nom, aes.sect_id, cvd_new(current_date, e.date_entree, 'new') FROM ass_entrep_sectact aes, entreprise e WHERE e.id = aes.ent_id and aes.sect_id <> 3 and aes.sect_id <> 9 and aes.sect_id <> 1 and aes.sect_id <> 13 and aes.sect_id <> 56 and aes.ent_id not in (SELECT ent_id FROM ass_entrep_sectact WHERE sect_id = 56 and sect_id <> 3 and sect_id <> 9 and sect_id <> 1 and sect_id <> 13) ORDER BY e.type, e.nom Now, if I want that my request works well, I have to remove the order by statement. But, of course, it is not ordered any more. So how can I translate this request to one which can work with an order by statement ? Thanks. -- Richard NAGY Presenceweb
[SQL]
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')); :) Kindly Apologize for any inconvenience. == He who invents adages for others to peruse takes along rowboat when going on cruise. == Regards, Bhuvaneswar. ---(end of broadcast)--- TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]
[SQL] How to Get Timestamp From SECONDS?
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')); :) Kindly Apologize for any inconvenience. == "Help Mr. Wizard!" -- Tennessee Tuxedo == Regards, Bhuvaneswar. ---(end of broadcast)--- TIP 4: Don't 'kill -9' the postmaster
Re: [SQL]
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.homeip.net/~peter ---(end of broadcast)--- TIP 3: if posting/reading through Usenet, please send an appropriate subscribe-nomail command to [EMAIL PROTECTED] so that your message can get through to the mailing list cleanly
Re: [SQL] Combine query views into one SQL string
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 2: you can get off all lists at once with the unregister command (send "unregister YourEmailAddressHere" to [EMAIL PROTECTED])
[SQL] Number the lines
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 ---(end of broadcast)--- TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]
Re: [SQL] Combine query views into one SQL string
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 TABLE2.AMOUNT 1 (amount) (amount) 2 (amount) (amount) . . . . . . You can achieve that result with an inner join (and even MySQL with it's rather restricted SQL subset supports an inner join). Nils -- Alles van waarde is weerloos Lucebert ---(end of broadcast)--- TIP 5: Have you checked our extensive FAQ? http://www.postgresql.org/users-lounge/docs/faq.html
[SQL] Urgent: How to set autocommit off in postgres.........
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 database. I have tried using the following code : create function abc() returns char as' begin begin work; insert into mytable values(1); // pseudo code if (conditions fails) then rollback work; end work; ... .. end; ' language 'plpgsql'; But this code fails miserably by not executing without errors since autocommit is on.Moreover I could not find ~/.psqlrc (or /etc/psqlrc). I am using Red Hat Linux 7.1 and Postgres 7.1.2. I badly in need of help as my deadline closes by to submit my project. Hope u would consider this as SOS call from ur friend. Waiting in anticipation of early reply, Regards, Advid Parmar New Delhi, India ---(end of broadcast)--- TIP 5: Have you checked our extensive FAQ? http://www.postgresql.org/users-lounge/docs/faq.html
Re: [SQL] Combine query views into one SQL string
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, Nils -- Alles van waarde is weerloos Lucebert ---(end of broadcast)--- TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]
[SQL] How do I extract ONE particular field, when multiple table contain the same field name?
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 'Category' (it is a text description field where you explain whatever you want). Therefore I get the following complaint when I run the query: Error msg: "The specified fiel 'DENOM' could refer to more than one table listed in the FROM clause of your SQL-statement" The DENOM-field I actually want is the one belonging to the XItem-table. I would most appreciate if someone could give me a hint how to alter the SELECT-statement above so that it does what I want. Regards /olw ---(end of broadcast)--- TIP 4: Don't 'kill -9' the postmaster
[SQL] array variables in pl/pgsql
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 unregister command (send "unregister YourEmailAddressHere" to [EMAIL PROTECTED])
[SQL] To query many tables.
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, table9 n, table10 ten, table 11 el, table 12 tw ... where f.id=s.id and f.id=t.id and f.id=fo.id and f.id=fi.id and so on... Is this the right way, or are there any better solution? How do the professionals make that big queries? Thanks in advance! Regards, Trebb ---(end of broadcast)--- TIP 5: Have you checked our extensive FAQ? http://www.postgresql.org/users-lounge/docs/faq.html
[SQL] array variable in pl/pgsql
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://www.postgresql.org/users-lounge/docs/faq.html
Re: [SQL] Combine query views into one SQL string
"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.id; > > Ciao Maik This is not right, i wouldnt even bather you if this was the simple answer. t1.id=t2.id would mean in doubled or tripled aggregation, since t1.id and t2.id are not unique, thats why I had to aggregate them in first Q1, Q2 querires, and link them by ID in the last one. I don't understand what UNION got to do here. then you probably have to make three union links of inner, left and right joined tables. This is not that easy as it seems. Is there a universal SQL string "expanding" rules, like in math or so? Thanks ---(end of broadcast)--- TIP 6: Have you searched our list archives? http://archives.postgresql.org
Re: [SQL] SQL request change when upgrade from 7.0.2 to 7.1.3
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 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_sectact aes, > > entreprise e WHERE e.id = aes.ent_id and aes.sect_id <> 3 and > aes.sect_id <> 9 > and aes.sect_id <> 1 and aes.sect_id <> 13 and aes.sect_id = 56 > UNION > SELECT distinct on (aes.ent_id) aes.ent_id, e.type, e.nom, aes.sect_id, > cvd_new(current_date, e.date_entree, 'new') FROM ass_entrep_sectact aes, > > entreprise e WHERE e.id = aes.ent_id and aes.sect_id <> 3 and > aes.sect_id <> 9 > and aes.sect_id <> 1 and aes.sect_id <> 13 and aes.sect_id <> 56 and > aes.ent_id > not in (SELECT ent_id FROM ass_entrep_sectact WHERE sect_id = 56 and > sect_id <> 3 > and sect_id <> 9 and sect_id <> 1 and sect_id <> 13) ORDER BY e.type, > e.nom > > Now, if I want that my request works well, I have to remove the order by > statement. But, of course, it is not ordered any more. > > So how can I translate this request to one which can work with an order > by statement ? > > Thanks. > > -- > Richard NAGY > Presenceweb > > > ---(end of broadcast)--- TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]
Re: [SQL] How do I extract ONE particular field, when multiple table contain the same field name?
[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 xi.Category=c.Index > > the problem is that the field 'DENOM' is present in both table 'XItem' > and > 'Category' (it is a text description field where you explain whatever > you > want). Therefore I get the following complaint when I run the query: > > Error msg: "The specified fiel 'DENOM' could refer to more than one > table listed > in the FROM clause of your SQL-statement" > > The DENOM-field I actually want is the one belonging to the > XItem-table. > I would most appreciate if someone could give me a hint how to alter > the > SELECT-statement above so that it does what I want. > > Regards > > /olw When joinning tables, as you did, it's hardly recommended using aliases, as you did too. (XItem <=> xi and Category <=> c). These aliases can be used in all the SELECT statement including WHERE clause, as you did again :), and SELECT clause. So, to refer to the DENOM field from the table XItem, you should write : xi.DENOM instead of DENOM alone. Your SELECT statement will be : Select XID, xi.DENOM, PRICE, FRT, CTID From XItem xi, Category c Where xi.System=1 and xi.Category=c.Index Notice than if you don't want to use aliases (what a wrong idea !), you can write like the following : Select XID, XItem.DENOM, PRICE, FRT, CTID From XItem, Category Where XItem.System=1 and XItem.Category=Category.Index Just some remarks about writing SQL statement. it's preferabled (in my point of view) to : - write key words (like SELECT, FROM, WHERE, ...) in upper case - go to the next line when you change of key word - always use aliases - keep always the same alias for the same table in all the queries - write the fields in lower case - write the first lettre of a table name in upper, the rest in lower case - use a "_ID" suffixe to the field name when it correspond to the primary key of another table - name "ID" the primary key of a table I would write your sql statement like : SELECT xi.ID, xi.denom, xi.price, xi.frt, cat.ID FROM XItem AS xi, Category AS cat WHERE xi.system = 1 AND xi.category_ID = cat.ID; good luck Yoann ---(end of broadcast)--- TIP 3: if posting/reading through Usenet, please send an appropriate subscribe-nomail command to [EMAIL PROTECTED] so that your message can get through to the mailing list cleanly
Re: [SQL] How do I extract ONE particular field, when multiple table contain the same field name?
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: How do I extract ONE particular field, when multiple table contain the same field name? > 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 > 'Category' (it is a text description field where you explain whatever > you > want). Therefore I get the following complaint when I run the query: > > Error msg: "The specified fiel 'DENOM' could refer to more than one > table listed > in the FROM clause of your SQL-statement" > > The DENOM-field I actually want is the one belonging to the > XItem-table. > I would most appreciate if someone could give me a hint how to alter > the > SELECT-statement above so that it does what I want. > > Regards > > /olw > > ---(end of broadcast)--- > TIP 4: Don't 'kill -9' the postmaster > > ---(end of broadcast)--- TIP 2: you can get off all lists at once with the unregister command (send "unregister YourEmailAddressHere" to [EMAIL PROTECTED])
Re: [SQL] Combine query views into one SQL string
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 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, > > Nils > > -- > Alles van waarde is weerloos > Lucebert ---(end of broadcast)--- TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]
Re: [SQL] Combine query views into one SQL string
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, you must also know that in this way you may not get all the records (sum of amount of all id-s) if this is your intention, but just sum of amount of identical id-s (contained in both tables). Maybe this will help you. "Eimas" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > "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.id; > > > > Ciao Maik > > This is not right, i wouldnt even bather you if this was the simple > answer. > > t1.id=t2.id would mean in doubled or tripled aggregation, > since t1.id and t2.id are not unique, thats why I had to aggregate > them in first Q1, Q2 querires, and link them by ID in the last one. > > I don't understand what UNION got to do here. then you probably have > to make three union links of inner, left and right joined tables. > > This is not that easy as it seems. > Is there a universal SQL string "expanding" rules, like in math or so? > > Thanks ---(end of broadcast)--- TIP 2: you can get off all lists at once with the unregister command (send "unregister YourEmailAddressHere" to [EMAIL PROTECTED])
[SQL] using LATIN1 ?
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(50));" I inserted this values "insert into test(f) values('áé');" It was ok now "select upper(f) from test;" gave me back "áé" -> expected "ÁÉ"; what's the problem ? ---(end of broadcast)--- TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]
[SQL] Which SQL query makes it possible to optain the 3 greatest values of an interger list ?
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 makes it possible to obtain Result from Table ? We certainly need to use sub-queries, but how ? Thank you in advance for your help ! Yoann AUBINEAU ---(end of broadcast)--- TIP 3: if posting/reading through Usenet, please send an appropriate subscribe-nomail command to [EMAIL PROTECTED] so that your message can get through to the mailing list cleanly
[SQL] array variable in pl/pgsql
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 send an appropriate subscribe-nomail command to [EMAIL PROTECTED] so that your message can get through to the mailing list cleanly
[SQL] array variable in pl/pgsql
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://www.postgresql.org/users-lounge/docs/faq.html
Re: [SQL] SQL request change when upgrade from 7.0.2 to 7.1.3
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 steps taken, including any error messages received. > Now, if I want that my request works well, I have to remove the order > by > statement. But, of course, it is not ordered any more. Er, by "request" do you mean "query"? Using an ORDER BY statement as you appear to use it in that query is permitted and correct. I suspect that your problem is located somewhere else. For example, what interface tool are you using to send queries to the database? -Josh __AGLIO DATABASE SOLUTIONS___ Josh Berkus Complete information technology [EMAIL PROTECTED] and data management solutions (415) 565-7293 for law firms, small businesses fax 621-2533 and non-profit organizations. San Francisco Hello Josh BERKUS, Thanks for your answer and sorry for my english. It was a query and not a request! Well, the query works well on postgresql 7.0.2 but when I upgraded the RDBS to 7.1.3, it did not work any more. The error was : Relation e does not exist. But, in the 'order by' statement, I removed the 'e.'. Now, the query works well without any error. It is ordered but I think it is certainly due to the fact that the table was already ordered on disk. So, I have no more errors but I'm not sure that it is completely good. PS : The interface tool that I have used to send queries to the database was psql. Regards -- Richard NAGY Presenceweb
Re: [SQL] How do I extract ONE particular field, when multiple table
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 unregister command (send "unregister YourEmailAddressHere" to [EMAIL PROTECTED])
Re: [SQL] SQL request change when upgrade from 7.0.2 to 7.1.3
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, including any error messages received. > Now, if I want that my request works well, I have to remove the order > by > statement. But, of course, it is not ordered any more. Er, by "request" do you mean "query"? Using an ORDER BY statement as you appear to use it in that query is permitted and correct. I suspect that your problem is located somewhere else. For example, what interface tool are you using to send queries to the database? -Josh __AGLIO DATABASE SOLUTIONS___ Josh Berkus Complete information technology [EMAIL PROTECTED] and data management solutions (415) 565-7293 for law firms, small businessesfax 621-2533 and non-profit organizations. San Francisco ---(end of broadcast)--- TIP 6: Have you searched our list archives? http://archives.postgresql.org
Re: [SQL] SQL request change when upgrade from 7.0.2 to 7.1.3
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 management solutions (415) 565-7293 for law firms, small businessesfax 621-2533 and non-profit organizations. San Francisco ---(end of broadcast)--- TIP 3: if posting/reading through Usenet, please send an appropriate subscribe-nomail command to [EMAIL PROTECTED] so that your message can get through to the mailing list cleanly
Re: [SQL] Number the lines
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 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 > > ---(end of broadcast)--- > TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED] > > ---(end of broadcast)--- TIP 4: Don't 'kill -9' the postmaster
Re: [SQL] Which SQL query makes it possible to optain the 3 greatest
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 T (v) VALUES (3); INSERT INTO T (v) VALUES (9); INSERT INTO T (v) VALUES (4); In that case you could do the following: SELECT v FROM T ORDER BY v DESC LIMIT 3; This will select the values, sort them in descending order and limit the result to 3 rows. I hope it helps. Regards, Patrik Kudo > 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 makes it possible to obtain Result from Table ? > We certainly need to use sub-queries, but how ? > > Thank you in advance for your help ! > > Yoann AUBINEAU ---(end of broadcast)--- TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]
Re: [SQL] How do I extract ONE particular field, when multiple table contain the same field name?
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 > > the problem is that the field 'DENOM' is present in both table 'XItem' > and 'Category' Just write: table.field or table-alias.field instead of just 'field' (like you did already in the WHERE clause): Select XID, xi.DENOM, PRICE, FRT, CTID >From XItem xi, Category c Where xi.System=1 and xi.Category=c.Index Christof -- gl.aser . software engineering . internet service http://gl.aser.de/ . Planckstraße 7 . D-39104 Magdeburg ---(end of broadcast)--- TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]
Re: [SQL] Which SQL query makes it possible to optain the 3 greatest values of an interger list ?
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: Wednesday, September 12, 2001 4:41 AM > To: [EMAIL PROTECTED] > Subject: [SQL] Which SQL query makes it possible to optain the 3 > greatest values of an interger list ? > > > 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 makes it possible to obtain Result from Table ? > We certainly need to use sub-queries, but how ? > > Thank you in advance for your help ! > > Yoann AUBINEAU > > ---(end of broadcast)--- > TIP 3: if posting/reading through Usenet, please send an appropriate > subscribe-nomail command to [EMAIL PROTECTED] so that your > message can get through to the mailing list cleanly > ---(end of broadcast)--- TIP 3: if posting/reading through Usenet, please send an appropriate subscribe-nomail command to [EMAIL PROTECTED] so that your message can get through to the mailing list cleanly