Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL code not returning all results

Status
Not open for further replies.

nutso98

Technical User
Mar 22, 2005
1
US
First off I'm a total SQL noob. So forgive me if this sounds bit stupid. I'm using an Excel spreadsheet to import External Data from Microsoft Query. I've been trying to modify this SQL statement:
Code:
SELECT a.NO_CLIE, b.NOM, a.NOTE_COMM, a.NO_COMM, a.NO_COMM_CLIE, a.DATE_COMM,a.stat_livr, a.DATE_EXPE, a.DATE_PREM_LIVR, a.DATE_ANNU, a.NO_LOCA, a.meth_tran,a.no_serv_tran,a.NOM_EXPE, a.ADRE_1_EXPE, a.ADRE_2_EXPE, a.VILLE_EXPE, a.CODE_POST_EXPE, a.RUE_TRAN_EXPE, a.TELE_EXPE, a.ETAT, a.TYPE_COMM, a.NO_TERM_PAIE, d.NO_PROD, g.NO_UPC, d.DESC_ITEM_1, d.TYPE_COMM, a.no_sous_type,d.date_livr,d.QUAN, f.QUAN_CALC, d.VALE_ESCO, d.PRIX_VENT_ORIG, d.PRIX_VENT, e.NOM, h.no_rama, h.date_rama, a.NO_TERM_PAIE_TRAN, a.PROV_EXPE, a.no_maga, a.code_maga

FROM gco_comm a, gcc_clie b, gco_item d, gsy_usag e, GCO_quan_item f, GCI_PROD g, gcov_rama_swing h  

WHERE a.NO_CLIE = b.NO_CLIE  AND a.NO_COMM = d.NO_CATE AND e.NO_EMPL = a.NO_EMPL AND f.NO_ITEM = d.NO_ITEM AND ((d.CATE_ITEM='C') AND (d.NO_PROD=g.no_prod)) AND D.NO_ITEM = H.NO_ITEM (+) 

ORDER BY a.NO_COMM  DESC
This code spits out a ton of results, but I just want to limit them by adding parameters. So I changed the WHERE clause to this:
Code:
WHERE a.NO_CLIE = b.NO_CLIE  AND a.NO_COMM = d.NO_CATE AND e.NO_EMPL = a.NO_EMPL AND f.NO_ITEM = d.NO_ITEM AND ((d.CATE_ITEM='C') AND (d.NO_PROD=g.no_prod)) AND D.NO_ITEM = H.NO_ITEM (+) AND (a.NO_CLIE=Decode(?,0,a.no_clie,?))
Which should return just the results based on a.no_clie all of the results if I input 0 RIGHT?!?!. But when I run it, Microsoft Query says I can't use parameters that are represented graphically. So with a little research, I found that this "(+)" was some type of JOIN and I couldn't use it with paramters. So I removed it, and it worked, but it didn't return results that had a NULL in the h.no_rama column.

Also the FROM clause changed on its own to this:
Code:
FROM <random username>.gco_comm a, <random username>.gcc_clie b, <random username>.gco_item d, <random username>.gsy_usag e, <random username>.GCO_quan_item f, <random username>.GCI_PROD g, gcov_rama_swing h
Does anyone have any clue what I'm talking about???
nut
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top