Re: [SQL] sql query problem

2012-01-17 Thread David Johnston
On Jan 17, 2012, at 8:35, Andreas Kretschmer wrote: > Alok Thakur wrote: > >> Dear, >> >> I am trying to provide you as much details as possible. >> >> answer` ( >> `id` int(10) NOT NULL AUTO_INCREMENT, >> `question_id` int(10) NOT NULL, >> `user_id` int(10) NOT NULL, >> `answer` int(10)

Re: [SQL] sql query problem

2012-01-17 Thread Andreas Kretschmer
Alok Thakur wrote: > Dear, > > I am trying to provide you as much details as possible. > > answer` ( > `id` int(10) NOT NULL AUTO_INCREMENT, > `question_id` int(10) NOT NULL, > `user_id` int(10) NOT NULL, > `answer` int(10) NOT NULL, -> > `status` tinyint(1) NOT NULL, --> Status wil

Re: [SQL] sql query problem

2012-01-17 Thread Alok Thakur
Dear, I am trying to provide you as much details as possible. answer` ( `id` int(10) NOT NULL AUTO_INCREMENT, `question_id` int(10) NOT NULL, `user_id` int(10) NOT NULL, `answer` int(10) NOT NULL, -> `status` tinyint(1) NOT NULL, --> Status will be 0 or 1 means wrong or right answer

Re: [SQL] sql query problem

2012-01-15 Thread Misa Simic
It seems question is not clear... I could not determine what should be in column Attended, and based on what should define passed/failed But quick tip would be SELECT name, CASE status WHEN 1 THEN 'Passed' ELSE 'Failed' END FROM UserTable INNER JOIN result ON UserTable.id = result.user_id Sent

Re: [SQL] sql query problem

2012-01-15 Thread Oliveiros
What does a 0 state mean? Failed? And a 1 state? Passed? Best, Oliveiros 2012/1/14 Alok Thakur > Dear All, > > I have two tables one contains details of user and other contains > result. The details are: > 1. UserTable - id, name, phone > 2. result - id, question_id, user_id, status (0 or 1) >

Re: [SQL] sql query question ?

2007-12-31 Thread Trilok Kumar
Dear Shane, Thanks for the reply and your observation about the word i have used. It is idle odometer reading. The actual Scenario is that the vehicle is taken by the driver. When he comes the next day. He is suppose to login again. Here i am trying to find out how much distance has the vehic

Re: [SQL] sql query question ?

2007-12-29 Thread Shane Ambler
Trilok Kumar wrote: Hi All, I have a table called vehicle_duty_cycle_summary vehicle_master_id | starting_odometer | ending_odometer | login_time | logout_time ---+---+-++---

Re: [SQL] sql query - create replace function

2007-12-20 Thread Richard Huxton
Iuri Sampaio wrote: Hi all, I created a script to install postgresql. One of the steps is to run a sql query. the problem is that i need to run the query as postgres user, plus it needs to be at psql shell prompt command line, i.e: Why does it need to be at the psql prompt? I expected somet

Re: [SQL] SQL query question

2007-10-07 Thread Rodrigo De León
On Sep 21, 12:09 am, [EMAIL PROTECTED] wrote: > Write the query (or queries if necessary) needed to count the number > of employees in each employee's department who are paid more than > their manager. SELECT e.dept, COALESCE (SUM (1), 0) AS n FROM employees e JOIN employees m ON (e

Re: [SQL] SQL query to display like this

2007-08-24 Thread Richard Huxton
RPK wrote: select PaySlipDate,EmpID, case ADCode when 'GPF' then ADAmount else 0 end GPF, case ADCode when 'GPF.ADV' then ADAmount else 0 end 'GPF.ADV' from EmpSalaryRecord It is showing like this: Date EmpID GPFGPF.ADV - 01-Jul-07 101

Re: [SQL] SQL Query Validate Records Multiple Tables - HelpNeeded

2007-05-16 Thread Bart Degryse
I'm working on something similar at the moment. Don't know about you, but I have an additional problem: I have to deal with rather large datasets (>2 recs per query) to be moved between the two databases (Oracle and PostgreSQL in my case). After doing lots of performance test, for me the con

Re: [SQL] SQL Query Validate Records Multiple Tables - Help Needed

2007-05-15 Thread Rodrigo De León
On May 15, 8:17 am, Paul251 <[EMAIL PROTECTED]> wrote: > Hello... > > I am trying to validate a asset number (10 Characters) from one table > to another table. Problem is they are in two different DB's and > haven't done that before? > > Basically trying to take record 1 from Table 1/DB1 and valida

Re: [SQL] SQL Query Newbie Help

2006-03-27 Thread Jim C. Nasby
On Fri, Mar 24, 2006 at 02:29:10PM -0800, Stephan Szabo wrote: > > On Fri, 24 Mar 2006, Julie Robinson wrote: > > > This works, but is there a better solution? > > > > select * > > from quality_control_reset T > > where date = ( > > select max(date) > > from quality_control_reset > >

Re: [SQL] SQL Query Newbie Help

2006-03-24 Thread Stephan Szabo
On Fri, 24 Mar 2006, Julie Robinson wrote: > This works, but is there a better solution? > > select * > from quality_control_reset T > where date = ( > select max(date) > from quality_control_reset > where qualitycontrolrange = T.qualitycontrolrange); If you can use PostgreSQL extens

Re: [SQL] SQL Query Newbie Help

2006-03-24 Thread Julie Robinson
This works, but is there a better solution? select * from quality_control_reset T where date = ( select max(date) from quality_control_reset where qualitycontrolrange = T.qualitycontrolrange); Julie Robinson wrote: Given the two tables at the bottom of this email, I'm having trouble c

Re: [SQL] SQL Query question

2005-06-30 Thread Nick Stone
Thanks for the reply at least that explains it. Nick -Original Message- From: Richard Huxton [mailto:[EMAIL PROTECTED] Sent: 30 June 2005 12:22 To: Nick Stone Cc: pgsql-sql@postgresql.org Subject: Re: [SQL] SQL Query question Nick Stone wrote: > Hi > > Whilst I'm not n

Re: [SQL] SQL Query question

2005-06-30 Thread Richard Huxton
Nick Stone wrote: Hi Whilst I'm not new to SQL I am reasonably new to Postgres and as such I have a question on the following query: FROM "Terms" As tbl1 LEFT JOIN "SearchStore" As tbl2 ON tbl1."KeywordID" = tbl2."KeywordID" AND tbl2."StockID" = 1 Why does the above query work fine an

Re: [SQL] SQL Query question

2005-06-30 Thread Peter Eisentraut
Am Donnerstag, 30. Juni 2005 11:27 schrieb Nick Stone: > SELECT > tbl1."TermTypeID", > tbl1."ParentID", > tbl1."KeywordID", > tbl1."Term", > tbl2."KeywordID" > FROM > "Terms" As tbl1 LEFT JOIN > "SearchStore" As tbl2 ON tbl1."KeywordID" = tbl2."KeywordID" > WHERE > (

Re: [SQL] SQL query help?

2005-03-07 Thread Michael Fuhr
On Mon, Mar 07, 2005 at 04:22:15PM -, John McGough wrote: > +---+---++-+--+ > | ID | JobID | UserID | Finished | Comment | > +---+---++-+--+ This table output doesn't look like PostgreSQL's usual format. > but I keep getting MySQL err

Re: [SQL] SQL query help?

2005-03-07 Thread Keith Worthington
John McGough wrote: SELECT Count(*) FROM Work WHERE (UserID='user1' AND MAX(Finished)=0) Work:- +---+---++-+--+ | ID | JobID | UserID | Finished | Comment | +---+---++-+--+ | 1 | 1| user1 | 0 | ...| | 2

Re: [SQL] SQL Query Performance tips

2005-01-31 Thread Michael Ossareh
Hi PFC Thanks for this! It has sped up complete - now in fact there is no delay! A few tweaks had to be made to the code ; here it is: select breakdown.alignment, sum(cnt) as num FROM ( (select alignment.name as class, count(1) as cnt from weapons, alignment where weapons

Re: [SQL] SQL Query Performance tips

2005-01-15 Thread PFC
If I understand well a person has all the free weapons which have a level <= to his own level, and of course all the weapons he bought. 1) get da weapons One query can only use one index. Bad for you ! Let's split the free and non-free weapons. 1a) free weapons S

Re: [SQL] SQL Query

2004-03-23 Thread Bruno Wolff III
On Tue, Mar 23, 2004 at 20:02:32 +, beyaNet Consultancy <[EMAIL PROTECTED]> wrote: > Hi, > I am trying to create a query which basically goes along the lines of: > > INSERT INTO tableX ( COL1, COL2 ) VALUES ( x, y ) where COL1 !=x and > COL2 !=Y > > So, insert a record into tableX where th

Re: [SQL] SQL query --- big question???

2004-03-12 Thread Richard Huxton
On Friday 12 March 2004 14:36, Andrei Bintintan wrote: > Hi to all, > > I have a big question. > > Can I write a query/function/agregate function (whatever) so that I can > return the result of a query in a single line? I don't know if this is > possible to be made and please if it is not possible

Re: [SQL] SQL query seach + rearranging results

2004-02-17 Thread Richard Huxton
On Monday 16 February 2004 16:07, lowdog wrote: > hey guys! > > I need your help in writing a php name-day searcher script. Actually, you probably want a mysql list - this is a PostgreSQL list. However, from what I can understand of your problem I think the easiest solution for you might be to o

Re: [SQL] SQL query

2004-02-04 Thread daq
PC> Hello, PC> I would like to retrieve all the records from table A which have given PC> lang_id and its modification date is later then modification date of PC> the same id record with lang_id='pl'. PC> Example: PC> table A - data example PC> == PC> id | modification_d

Re: [SQL] SQL Query for Top Down fetching of childs

2004-01-29 Thread Kumar
ED]> Sent: Thursday, January 29, 2004 3:57 PM Subject: Re: [SQL] SQL Query for Top Down fetching of childs > On Thursday 29 January 2004 06:11, Kumar wrote: > > Dear Friends, > > > > Postgres 7.3.4 on RH Linux 7.2. > > > > I need a query to get the Childs of a par

Re: [SQL] SQL Query for Top Down fetching of childs

2004-01-29 Thread Richard Huxton
On Thursday 29 January 2004 06:11, Kumar wrote: > Dear Friends, > > Postgres 7.3.4 on RH Linux 7.2. > > I need a query to get the Childs of a parent (Top down analysis). Need to > list all the departments(Childs) of a parent organization. The table > structure is Two places to look for examples: 1

Re: [SQL] sql query with join and parameter in postgresql function

2004-01-16 Thread Philippe Lang
> > I thought a view would be more appropriate, but > > if I'm not wrong, a view does not accept any parameter > > as input... > > But you can just define the view and select it with a WHERE clause with > your parameter, just like a normal table. Would that help? Thanks! That's perfect. I join in

Re: [SQL] sql query with join and parameter in postgresql function

2004-01-16 Thread Michael Glaesemann
On Jan 16, 2004, at 8:30 PM, Philippe Lang wrote: Hello, I'd like to write a function similar to that: CREATE FUNCTION public.report_join_parameter(char(6)) RETURNS ??? AS Do I ***HAVE TO*** define a composite type for the columns my function

Re: [SQL] SQL query problem

2003-10-09 Thread Stuart Barbee
Marek, Not sure but, try switching the lines db_data.mda_mod_con _CON, db_data.set_mda_fue _FUE with db_data.set_mda_fue _FUE, db_data.mda_mod_con _CON so there query is: SELECT _CON.con_id, _MOD.mod_ty, _VER.version, _YEA.year, _CON.dri_id, _CON.man_cod, _ENG.eng_p

Re: [SQL] SQL query problem

2003-10-09 Thread Bruno Wolff III
On Thu, Oct 09, 2003 at 20:52:58 +0100, Marek Lewczuk <[EMAIL PROTECTED]> wrote: > Hello, > I'm in the middle of the migration process from MySQL to PostgreSQL and > I cannot understand why this query isn't working (in MySQL it's working > fine). PG returns: ERROR: Relation "_con" does not exist

Re: [SQL] sql query

2002-12-11 Thread Christoph Haller
> > Hi I have a problem forming a query > I have 3 tables salary(hrs, clock_in , clock_out) > Break ( date, employe_id, net_time, break_in, break_out) > Employee(employee_id, pay_rate, name) > > I need to get an hourly report till the current time for that day > stating name, hour, no of hours, sal

Re: [SQL] SQL QUERY

2002-12-03 Thread Achilleus Mantzios
mply and nicely use sequences. > Pedro Igor > > - Original Message - > From: "Achilleus Mantzios" <[EMAIL PROTECTED]> > To: "Pedro Igor" <[EMAIL PROTECTED]> > Cc: <[EMAIL PROTECTED]> > Sent: Tuesday, December 03, 2002 11:05

Re: [SQL] SQL QUERY

2002-12-03 Thread Achilleus Mantzios
On Tue, 3 Dec 2002, Pedro Igor wrote: > I have the following function: > CREATE FUNCTION public.auto_incremento() RETURNS trigger AS ' > begin > new.id = (select (max(id) + 1) from teste); > return new; > end;' LANGUAGE 'plpgsql' > > I created a trigger that uses this function, but i want to the f

Re: [SQL] SQL query help!

2002-11-28 Thread Arcadius A.
Hello! "Luis Sousa" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > This is a cryptographically signed message in MIME format. > > --ms080209060900030807050408 > Content-Type: text/plain; charset=us-ascii; format=flowed > Content-Transfer-Encoding: 7

Re: [SQL] SQL query help!

2002-11-27 Thread Luis Sousa
Tell me what did you try with limit and group by. Where's IN, why don't you use EXISTS instead. It runs much master ! Regards, Luis Sousa Arcadius A. wrote: Hello! I hope that someone here could help. I'm using PostgreSQL7.1.3 I have 3 tables in my DB: the tables are defined in the following

Re: [SQL] SQL Query

2001-09-12 Thread Miguel González
Sorry If i didnt make clear which are the fields and which are the tables. The tables are the ones "underlined", so I have cdroms, items, cdroms_items, loans and reservations. I just left the important fields in order not to confuse the people, and just wrote the name of the fields that are the p

Re: [SQL] SQL Query Results

2001-01-24 Thread Christopher Sawtell
On Wed, 24 Jan 2001 18:02, wrote: > I want to show a certain person the commands I type and the query results, > and I want to save them in a file. I tried \e filename and \E filename and > its not working. Can someone please help me?? I don't know if this is available on your particular machine

Re: [SQL] SQL query not working when GROUP BY / HAVING is used

2000-12-19 Thread Jie Liang
Hope it helps: 1. If you use GROUP, the select list should sum|count|max ..., no single field. 2. If you use NULL, the condition should be field IS [NOT] NULL, = NULL will give the wrong answer. Jie LIANG Internet Products Inc. 10350 Science Center Drive Suite 100, San Diego, CA 92121 O

Re: [SQL] SQL query not working when GROUP BY / HAVING is used

2000-12-19 Thread Jie Liang
I hope it may help: 1. if you use group clause in a select stmt, the select list must be agregate function such as sum(field),count(field), max(field)..., cannot use field. 2. for field have NULL field, should use field IS NULL, = NULL will give you wrong result! Jie LIANG Internet Products In

Re: [SQL] SQL query not working when GROUP BY / HAVING is used

2000-12-19 Thread Stephan Szabo
On Tue, 19 Dec 2000 [EMAIL PROTECTED] wrote: > Hello there > > I have a question regarding a SQL statement. > > When I execute (and that's what I need) > > SELECT Zylinder.Z_durch_soll, Zylinder.Z_id, Zylinder.Z_durch_ist, > ((Zylinder.Z_durch_soll+0.12) - Zylinder.Z_durch_ist) AS durchmesserd

Re: [SQL] SQL Query using time

2000-12-12 Thread Blaise Carrupt
> Is it possible to carry out the comparison in the following manner > select name from table where 00:12 is between 23:58 and 00:30 You could try something like WHERE ('00:12' BETWEEN startTime AND endTime AND startTime <= endTime) OR ('00:12' NOT BETWEEN endTime AND startTime

Re: [SQL] sql query not using indexes

2000-09-22 Thread Stephan Szabo
On Fri, 22 Sep 2000, Tom Lane wrote: > indexscans; the current code may have overcorrected a shade, but I think > it's closer to reality than 6.5 was. > > As Hiroshi already commented, the difference in results suggests that > the desired data is very nonuniformly scattered in the table. 7.0 >

Re: [SQL] sql query not using indexes

2000-09-22 Thread Tom Lane
Stephan Szabo <[EMAIL PROTECTED]> writes: >> Ok I agree with you on the real database there are 127,300 rows and there >> are certanly a great number of rows > 'AAA'. But, supose I make a query >> select * from table where code > 'AAA' limit 10. it will read the entire >> table only to give me the

RE: [SQL] sql query not using indexes

2000-09-21 Thread Hiroshi Inoue
> -Original Message- > From: Sergio de Almeida Lenzi > > On Wed, 20 Sep 2000, Stephan Szabo wrote: > > > On Wed, 20 Sep 2000, User Lenzi wrote: > > > > > if I start a query: > > > > > > explain select * from teste where login = 'xxx' > > > results: > > > Index Scan using teste1 on teste

Re: [SQL] sql query not using indexes

2000-09-21 Thread Stephan Szabo
On Thu, 21 Sep 2000, Sergio de Almeida Lenzi wrote: > > > On a machine running version 6.5 both queries results index scan. > > > > > > this results that the version 6.5 is faster than version 7.0.2 on this > > > kind of > > > query. > > > > > > > > > Any explanation??? > > > > Have you done

Re: [SQL] sql query not using indexes

2000-09-21 Thread Sergio de Almeida Lenzi
On Wed, 20 Sep 2000, Stephan Szabo wrote: > On Wed, 20 Sep 2000, User Lenzi wrote: > > > if I start a query: > > > > explain select * from teste where login = 'xxx' > > results: > > Index Scan using teste1 on teste (cost=0.00..97.88 rows=25 ) > > > > > > however a query: > > explain selec

Re: [SQL] sql query not using indexes

2000-09-20 Thread Mitch Vincent
i" <[EMAIL PROTECTED]> Cc: "pgsql-sql" <[EMAIL PROTECTED]> Sent: Wednesday, September 20, 2000 11:23 AM Subject: Re: [SQL] sql query not using indexes > On Wed, 20 Sep 2000, User Lenzi wrote: > > > if I start a query: > > > > explain select * fro

Re: [SQL] sql query not using indexes

2000-09-20 Thread Stephan Szabo
On Wed, 20 Sep 2000, User Lenzi wrote: > if I start a query: > > explain select * from teste where login = 'xxx' > results: > Index Scan using teste1 on teste (cost=0.00..97.88 rows=25 ) > > > however a query: > explain select * from teste where login > 'AAA' > results: > Seq Scan on teste .