i have two dataset parameters but when p1 is given data should give me result set from all related data from p1 (Where condition 1), when p2 is is given data should give me result data from p2( where condition 2). But when p1 and p2 both have entered data , result set should have combination of both(where condition 3).. my SQL Query working perfectly in MY SQL but in dataset SQL its not working as expected. Need help on the same.By query is as follows:
select col1,col2,col3,col4 from table1 where
(col1=<<$p1>> and <<$p2>>=“”) or
(<<$p1>>=“” and col2=<<$p2>>) or
(col1=<<$p1>> and col2=<<$p2>>)
Can you modify your query to check for NULL instead of “”? Since you will be mapping the parameter from the analysis, it would be reset to blank I am assuming.
i tried with below query, always showing data only when two values are populated. not giving values when one parameter is populated from text field:
select col1,col2,col3,col4 from table1 where
(col1=<<$p1>> and <<$p2>> is NULL) or
(<<$p1>> is NULL and col2=<<$p2>>) or
(col1=<<$p1>> and col2=<<$p2>>)
hi. i have tried this approach in teh first place.. but not giving the desired output..
below are my expected outputs…
p1 is 4 digit Id
p2 is Month 01,02,.. 12
when i enter p1 ID 0001 it should give me all data having ID 0001 for all months…
when i enter p2 as 04 that is april data should give me all IDs of 04 April month data
when i give p1 0001 and p2 04.. it should only give me data of ID 0001 amonth 04… the third use case not getting hit.. right now showing all data( all Ids) of 04 and plus ID 0001 for all months.. which is incorrect..
In this >>> IFNULL(<<$P1>>, ‘0000’) = ‘0000’ ) >> the 0000 should be replaced with your default value
In this >>> IFNULL(<<$P2>>, ‘00’) = ‘00’ >> the 00 should be replaced with your default value