Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 9239

Using Command to fix null / left outer join issue

$
0
0

Hi

 

I was told awhile ago that it's possible to fix crystal's issue with left outer join and null records being eliminated.

 

I think i remember most of how this goes, but i can't seem to duplicate it.

 

1) You can't have any select expert -- record
2) You create the report normally and then make a new report using the SQL Query

     - Can't remember if its the whole report or upto the tables that have hisotry (null results)

3) You move parts from WHERE to FROM

 

Hopefully someone can help correct the steps i'm doing wrong or add what i'm missing from this.

 

Below is the Query from my comlpeted report, but when i run it with the last LEFT OUTER JOIN added it removes all the products with no sales during that year.

 

Any help would be greatly appreciated even if it's to say this can't be done.

 

SELECT

"prod_warehouse"."pw_whs_id",

"prod_warehouse"."pw_prodline_id",

"prod_warehouse"."pw_prod_id",

"prod_warehouse"."pw_bin_location1",

"prod_warehouse"."pw_min_onhand_qty",

"prod_warehouse"."pw_max_onhand_qty",

"prod_warehouse"."pw_onhand_qty",

"product_lookup"."prlkp_lang1_1_desc",

"prod_customer"."prcu_cust_part_num",

"contract_details"."cond_level1_amt",

"sales_history"."sah_year"

 

FROM   (((("sisl_data05"."dbo"."products" "products"

 

LEFT OUTER  JOIN "sisl_data05"."dbo"."prod_warehouse" "prod_warehouse"

ON ("products"."pr_prod_id"="prod_warehouse"."pw_prod_id")

AND ("products"."pr_prodline_id"="prod_warehouse"."pw_prodline_id"))

 

LEFT OUTER JOIN "sisl_data05"."dbo"."product_lookup" "product_lookup"

ON ("products"."pr_prod_id"="product_lookup"."prlkp_prod_id")

AND ("products"."pr_prodline_id"="product_lookup"."prlkp_prodline_id"))

 

LEFT OUTER JOIN "sisl_data05"."dbo"."prod_customer" "prod_customer"

ON ("products"."pr_prod_id"="prod_customer"."prcu_prod_id")

AND ("products"."pr_prodline_id"="prod_customer"."prcu_prodline_id"))

 

LEFT OUTER JOIN "sisl_data05"."dbo"."contract_details" "contract_details"

ON "prod_warehouse"."pw_prod_id"="contract_details"."cond_prod_id")

 

LEFT OUTER JOIN "sisl_data05"."dbo"."sales_history" "sales_history"

ON (("prod_warehouse"."pw_whs_id"="sales_history"."sah_sortkey1")

AND ("prod_warehouse"."pw_prod_id"="sales_history"."sah_sortkey2"))

AND ("prod_warehouse"."pw_prodline_id"="sales_history"."sah_sortkey3")

 

WHERE

"prod_warehouse"."pw_whs_id"='20123'

AND ("prod_warehouse"."pw_onhand_qty"<>0

OR "prod_warehouse"."pw_bin_location1"<>'  '

OR "prod_warehouse"."pw_max_onhand_qty">0)

AND "sales_history"."sah_year"=2014

 

ORDER BY "prod_warehouse"."pw_bin_location1", "prod_warehouse"."pw_prod_id"


Viewing all articles
Browse latest Browse all 9239

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>