Subject | Help with query neaded |
---|---|
Author | Zoran Zivkovic |
Post date | 2006-02-28T10:44:45Z |
I have folowing tables in database
CREATE TABLE ARTIKLI (
SIFRA_PROIZ VARCHAR(25),
STANJE DOUBLE PRECISION);
CREATE TABLE SIFARNIK_PJ (
POSLOVNICA_ID INTEGER NOT NULL,
OPIS VARCHAR(30));
CREATE TABLE STANJE_PJ (
SIFRA_PROIZ VARCHAR(35) NOT NULL,
SIFRA_SKLAD INTEGER NOT NULL,
STANJE INTEGER);
In Short, Table artikli hold data about all products in our database.
Table SIFARNIK_PJ lists all our warehouses, and table STANJE_PJ keep
data about part numbers available in other warehouses except central
warehouse. My query (which doesn't give me what i need is):
SELECT
A.SIFRA_PROIZ,
A.STANJE,
SPJ.STANJE
FROM ARTIKLI A
LEFT OUTER JOIN STANJE_PJ SPJ ON (SPJ.SIFRA_PROIZ=A.SIFRA_PROIZ)
WHERE A.SIFRA_PROIZ LIKE 'C%' AND SPJ.SIFRA_SKLAD=1
Table Artikli has 1200 rows with field SIFRA_PROIZ starting with 'c'.
Table STANJE_PJ has 121 row with field SIFRA_PROIZ starting with 'c'
and sifra_sklad=1. I need query which will return 1200 rows, and in
3rd column I need NULLs where there is no coresponding record in Table
STANJE_PJ. I hope this I was clear, :).
Regards
Zile
P.S. I Still can't post messages from OE to newsgroup. Any help?
CREATE TABLE ARTIKLI (
SIFRA_PROIZ VARCHAR(25),
STANJE DOUBLE PRECISION);
CREATE TABLE SIFARNIK_PJ (
POSLOVNICA_ID INTEGER NOT NULL,
OPIS VARCHAR(30));
CREATE TABLE STANJE_PJ (
SIFRA_PROIZ VARCHAR(35) NOT NULL,
SIFRA_SKLAD INTEGER NOT NULL,
STANJE INTEGER);
In Short, Table artikli hold data about all products in our database.
Table SIFARNIK_PJ lists all our warehouses, and table STANJE_PJ keep
data about part numbers available in other warehouses except central
warehouse. My query (which doesn't give me what i need is):
SELECT
A.SIFRA_PROIZ,
A.STANJE,
SPJ.STANJE
FROM ARTIKLI A
LEFT OUTER JOIN STANJE_PJ SPJ ON (SPJ.SIFRA_PROIZ=A.SIFRA_PROIZ)
WHERE A.SIFRA_PROIZ LIKE 'C%' AND SPJ.SIFRA_SKLAD=1
Table Artikli has 1200 rows with field SIFRA_PROIZ starting with 'c'.
Table STANJE_PJ has 121 row with field SIFRA_PROIZ starting with 'c'
and sifra_sklad=1. I need query which will return 1200 rows, and in
3rd column I need NULLs where there is no coresponding record in Table
STANJE_PJ. I hope this I was clear, :).
Regards
Zile
P.S. I Still can't post messages from OE to newsgroup. Any help?