Join or Where? - Mailing list pgsql-sql
From | Együd Csaba |
---|---|
Subject | Join or Where? |
Date | |
Msg-id | 003301c33bd5$198f7250$230a0a0a@compaq Whole thread Raw |
In response to | Urgent Help : Use of return from function/procedure. ("Anagha Joshi" <ajoshi@nulinkinc.com>) |
Responses |
Re: Join or Where?
|
List | pgsql-sql |
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
--------------------------------------------------------------------
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
--------------------------------------------------------------------
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
--------------------------------------------------------------------