X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.193]) by svr1.postgresql.org (Postfix) with ESMTP id F0F2330FED7 for ; Thu, 26 Jun 2003 11:23:24 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (svr1.postgresql.org [64.117.224.193]) (amavisd-new, port 10024) with ESMTP id 30592-09 for ; Thu, 26 Jun 2003 08:23:14 -0300 (ADT) Received: from vadangyal.vnet.hu (mail.vnet.hu [213.163.59.4]) by svr1.postgresql.org (Postfix) with ESMTP id C4D9530FEE8 for ; Thu, 26 Jun 2003 08:23:13 -0300 (ADT) Received: from compaq (adsl213150.vnet.hu [62.77.213.150]) by mail.vnet.hu (iPlanet Messaging Server 5.1 Patch 1 (built Jun 6 2002)) with ESMTPA id <0HH300JEG68FYK@mail.vnet.hu> for pgsql-sql@postgresql.org; Thu, 26 Jun 2003 13:21:52 +0200 (CEST) Date: Thu, 26 Jun 2003 13:21:27 +0200 From: =?iso-8859-1?Q?Egy=FCd_Csaba?= Subject: Join or Where? To: pgsql-sql@postgresql.org Reply-To: =?iso-8859-1?Q?Egy=FCd_Csaba?= Message-id: <003301c33bd5$198f7250$230a0a0a@compaq> MIME-version: 1.0 X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2727.1300 X-Mailer: Microsoft Outlook Express 6.00.2720.3000 Content-type: multipart/alternative; boundary="Boundary_(ID_cC/tIInhUME7ElTWVOsEKQ)" X-Priority: 3 X-MSMail-priority: Normal References: X-Archive-Number: 200306/293 X-Sequence-Number: 14051 This is a multi-part message in MIME format. --Boundary_(ID_cC/tIInhUME7ElTWVOsEKQ) Content-type: text/plain; charset=iso-8859-1 Content-transfer-encoding: 7BIT Urgent Help : Use of return from function/procedure.Hi, could anybody tell me what can be the difference between these queries? There are a big difference but I can't understand the reasons. For some reasons the firs query calculates getup column in a wrong way. It allways devides with 10. (???) While the getupquantity column comes well. With the second query everything is ok. Thank you, -- Csaba ---------------------------------------------------------------------------- ------- select (select getupquantity from t_products where id=productid) as getupquantity, quantity, (select quantity/getupquantity) as getup from t_stockchanges, t_products where (getupquantity<>0) limit 30; RESULT: getupquantity | quantity | getup ---------------+----------+------- 10 | 100 | 10 10 | 10600 | 1060 15 | 15150 | 1515 13 | 13650 | 1365 17.5 | 17500 | 1750 5.75 | 5750 | 575 2.5 | 2500 | 250 1.5 | 1500 | 150 16 | 16000 | 1600 2 | 2000 | 200 5.5 | 5500 | 550 4.5 | 4500 | 450 2 | 2000 | 200 ---------------------------------------------------------------------------- ------- select t_products.getupquantity as getupquantity, quantity, (select t_stockchanges.quantity/t_products.getupquantity) as getup from t_stockchanges join t_products on (t_products.id=productid) where (getupquantity<>0) limit 30; RESULT: getupquantity | quantity | getup ---------------+----------+------- 10 | 100 | 10 10 | 10600 | 1060 15 | 15150 | 1010 13 | 13650 | 1050 17.5 | 17500 | 1000 5.75 | 5750 | 1000 2.5 | 2500 | 1000 1.5 | 1500 | 1000 16 | 16000 | 1000 2 | 2000 | 1000 5.5 | 5500 | 1000 4.5 | 4500 | 1000 2 | 2000 | 1000 -------------------------------------------------------------------- Hi, could anybody tell me what can be the difference between these queries? There are a big difference but I can't understand the reasons. For some reasons the firs query calculates getup column in a wrong way. It allways devides with 10. (???) While the getupquantity column comes well. With the second query everything is ok. Thank you, -- Csaba ---------------------------------------------------------------------------- ------- select (select getupquantity from t_products where id=productid) as getupquantity, quantity, (select quantity/getupquantity) as getup from t_stockchanges, t_products where (getupquantity<>0) limit 30; RESULT: getupquantity | quantity | getup ---------------+----------+------- 10 | 100 | 10 10 | 10600 | 1060 15 | 15150 | 1515 13 | 13650 | 1365 17.5 | 17500 | 1750 5.75 | 5750 | 575 2.5 | 2500 | 250 1.5 | 1500 | 150 16 | 16000 | 1600 2 | 2000 | 200 5.5 | 5500 | 550 4.5 | 4500 | 450 2 | 2000 | 200 ---------------------------------------------------------------------------- ------- select t_products.getupquantity as getupquantity, quantity, (select t_stockchanges.quantity/t_products.getupquantity) as getup from t_stockchanges join t_products on (t_products.id=productid) where (getupquantity<>0) limit 30; RESULT: getupquantity | quantity | getup ---------------+----------+------- 10 | 100 | 10 10 | 10600 | 1060 15 | 15150 | 1010 13 | 13650 | 1050 17.5 | 17500 | 1000 5.75 | 5750 | 1000 2.5 | 2500 | 1000 1.5 | 1500 | 1000 16 | 16000 | 1000 2 | 2000 | 1000 5.5 | 5500 | 1000 4.5 | 4500 | 1000 2 | 2000 | 1000 -------------------------------------------------------------------- --Boundary_(ID_cC/tIInhUME7ElTWVOsEKQ) Content-type: text/html; charset=iso-8859-1 Content-transfer-encoding: 7BIT Urgent Help : Use of return from function/procedure.
Hi,
could anybody tell me what can be the difference between these queries?
There are a big difference but I can't understand the reasons. For some
reasons the firs query calculates getup column in a wrong way. It allways
devides with 10. (???) While the getupquantity column comes well.

With the second query everything is ok.

Thank you,

-- Csaba

----------------------------------------------------------------------------
-------
select (select getupquantity from t_products where id=productid) as
getupquantity,
       quantity,
       (select quantity/getupquantity) as getup
from t_stockchanges, t_products
where (getupquantity<>0)
limit 30;

RESULT:
 getupquantity | quantity | getup
---------------+----------+-------
            10 |      100 |    10
            10 |    10600 |  1060
            15 |    15150 |  1515
            13 |    13650 |  1365
          17.5 |    17500 |  1750
          5.75 |     5750 |   575
           2.5 |     2500 |   250
           1.5 |     1500 |   150
            16 |    16000 |  1600
             2 |     2000 |   200
           5.5 |     5500 |   550
           4.5 |     4500 |   450
             2 |     2000 |   200
----------------------------------------------------------------------------
-------
select t_products.getupquantity as getupquantity,
       quantity,
       (select t_stockchanges.quantity/t_products.getupquantity) as getup
from t_stockchanges
join t_products on (t_products.id=productid)
where (getupquantity<>0)
limit 30;

RESULT:
getupquantity | quantity | getup
---------------+----------+-------
            10 |      100 |    10
            10 |    10600 |  1060
            15 |    15150 |  1010
            13 |    13650 |  1050
          17.5 |    17500 |  1000
          5.75 |     5750 |  1000
           2.5 |     2500 |  1000
           1.5 |     1500 |  1000
            16 |    16000 |  1000
             2 |     2000 |  1000
           5.5 |     5500 |  1000
           4.5 |     4500 |  1000
             2 |     2000 |  1000
--------------------------------------------------------------------
Hi,
could anybody tell me what can be the difference between these queries?
There are a big difference but I can't understand the reasons. For some
reasons the firs query calculates getup column in a wrong way. It allways
devides with 10. (???) While the getupquantity column comes well.

With the second query everything is ok.

Thank you,

-- Csaba

----------------------------------------------------------------------------
-------
select (select getupquantity from t_products where id=productid) as
getupquantity,
       quantity,
       (select quantity/getupquantity) as getup
from t_stockchanges, t_products
where (getupquantity<>0)
limit 30;

RESULT:
 getupquantity | quantity | getup
---------------+----------+-------
            10 |      100 |    10
            10 |    10600 |  1060
            15 |    15150 |  1515
            13 |    13650 |  1365
          17.5 |    17500 |  1750
          5.75 |     5750 |   575
           2.5 |     2500 |   250
           1.5 |     1500 |   150
            16 |    16000 |  1600
             2 |     2000 |   200
           5.5 |     5500 |   550
           4.5 |     4500 |   450
             2 |     2000 |   200
----------------------------------------------------------------------------
-------
select t_products.getupquantity as getupquantity,
       quantity,
       (select t_stockchanges.quantity/t_products.getupquantity) as getup
from t_stockchanges
join t_products on (t_products.id=productid)
where (getupquantity<>0)
limit 30;

RESULT:
getupquantity | quantity | getup
---------------+----------+-------
            10 |      100 |    10
            10 |    10600 |  1060
            15 |    15150 |  1010
            13 |    13650 |  1050
          17.5 |    17500 |  1000
          5.75 |     5750 |  1000
           2.5 |     2500 |  1000
           1.5 |     1500 |  1000
            16 |    16000 |  1000
             2 |     2000 |  1000
           5.5 |     5500 |  1000
           4.5 |     4500 |  1000
             2 |     2000 |  1000
--------------------------------------------------------------------
--Boundary_(ID_cC/tIInhUME7ElTWVOsEKQ)--