Can someone guide me thru on how to make this happen, I have a report to generate which will let a user select Customer,SalesRep,Location & Product. I need to write a query which will let the user the parameter value, It’s basically a multifunctional query that generates whatever is selected on the pic list. If you select “N” for anything it then allows you to select other criteria. For instance…I may want to see a monthly selection of shipments of Special Select to all customers, or a selection of customers. Or….a selection of all fish meal products to a group of 10 customers….and so on
select distinct T1. C01_CMM_S , T1. c01_GROSS_DATE_T_AS_A_DATE , T2. C05_CMM_DESC_S as Prodname , case when {fn MONTH(T1. c01_GROSS_DATE_T_AS_A_DATE )} = 1 then case when T1. C01_CMM_S in ('A5', 'B2', 'B5', 'B6', 'D2') then T1. C07_CUS_NET_UNTS_D / 2204.6 when T1. C01_CMM_S in ('G1', 'G3', 'L1', 'N1', 'O1') then T1. C07_CUS_NET_UNTS_D * 1.1023 when T1. C01_CMM_S = 'O2' then T1. C07_CUS_NET_UNTS_D / 2000 else T1. C07_CUS_NET_UNTS_D end else 0 end January, {fn YEAR(T1. c01_GROSS_DATE_T_AS_A_DATE )} Month, case when {fn MONTH(T1. c01_GROSS_DATE_T_AS_A_DATE )} = 2 then case when T1. C01_CMM_S in ('A5', 'B2', 'B5', 'B6', 'D2') then T1. C07_CUS_NET_UNTS_D / 2204.6 when T1. C01_CMM_S in ('G1', 'G3', 'L1', 'N1', 'O1') then T1. C07_CUS_NET_UNTS_D * 1.1023 when T1. C01_CMM_S = 'O2' then T1. C07_CUS_NET_UNTS_D / 2000 else T1. C07_CUS_NET_UNTS_D end else 0 end Febuary , case when {fn MONTH(T1. c01_GROSS_DATE_T_AS_A_DATE )} = 3 then case when T1. C01_CMM_S in ('A5', 'B2', 'B5', 'B6', 'D2') then T1. C07_CUS_NET_UNTS_D / 2204.6 when T1. C01_CMM_S in ('G1', 'G3', 'L1', 'N1', 'O1') then T1. C07_CUS_NET_UNTS_D * 1.1023 when T1. C01_CMM_S = 'O2' then T1. C07_CUS_NET_UNTS_D / 2000 else T1. C07_CUS_NET_UNTS_D end else 0 end March, T3. Primary_Sales from C05_COMMODITY_CODE T2, trns_Agris_shipment T1 LEFT OUTER JOIN pres_ShipToCust_specie_Salesrep T3 on T1. C01_CMM_S = T3. C01_CMM_S and T1. c01_shp_to_fr_id_s = T3. N01_NAM_ID_S where T1. C01_CMM_S = T2. C05_COMM_CD_S and (T1. C01_CMM_S in (@Product) or @AllProduct = 'Y') and {fn YEAR(T1. c01_GROSS_DATE_T_AS_A_DATE )} = @Year and T1. c01_tkt_type_s = 'R' and T1. c01_weight_base_s in ('F') and (T1. c01_shp_to_fr_id_s in (@Ship2Cust) or @AllShipto = 'Y') and (T3. Primary_Sales in (@Salesrep) or @AllSalesRep= 'Y') and (T1. C01_LOC_S in (@Location) or @AllLocation = 'Y') order by 7 asc , 1 asc , 8 asc , 9 asc , 10 asc , 12 asc
I have 8 Parameters in this query If the value of Parameter is 'Y' to select all Prods, location.customers,salesreps it selects all and If its entered as 'N' then a user should have ability to Multi select the value..
Does that make sense? Please Help !!!
FM