Hi,

I have to generate Report from several tables.

I have written Queries depends on logic but i dont know how to combine these queries..

user will be giving id,date,destination then i have to generate what r the values assigned updated on that given date for given destination..
so i designed tables to insert all values before updations in original table.
in tat no constraints and primary keys..

I have written Queries depends on logic but i dont know how to combine these queries to smaller number putting in java code in single interface..

Anybody help plz..
see the following queries.

am so confused to combine.




subscriberStartTime:
select modified_date from audit_subscriber_master where subscriber_id='"+subscriber_id+"' and modified_date<'"+time+"' order by modified_date desc limit 1;

subscriberEndTime:
select modified_date,bp_code from audit_subscriber_master where subscriber_id='"+subscriber_id+"' and modified_date>'"+time+"' order by modified_date limit 1;

if(subscriberEndTime = null)
subscriberEndTime=subscriberStartTime

calendarBillingStartTime:
select modified_date,bp_seq_no from audit_calendar_billing where bp_code='"+subscriberBpCode+"' and modified_date<'"+subscriberModifiedDate+"' order by modified_date desc limit 1;

calendarEndTime:
select modified_date from audit_calendar_billing where bp_code='"+subscriberBpCode+"' and modified_date>'"+subscriberModifiedDate+"' order by modified_date limit 1;

if(subscriberEndTime = null)
subscriberEndTime=subscriberStartTime

bpRuleMappingStartTime:
select modified_date from audit_calendar_billing where bp_seq_no="calendarBillingSeqNo" and modified_date<'"+subscriberModifiedDate+"' order by modified_date desc limit 1;

bpRuleMappingEndTime:
select modified_date,rule_id from audit_calendar_billing where bp_seq_no="calendarBillingSeqNo" and modified_date>'"+subscriberModifiedDate+"' order by modified_date limit 1;

if(bpRuleMappingEndTime = null)
bpRuleMappingEndTime=bpRuleMappingStartTime


addressRuleEndTime:
select modified_date,pulse_rule_id from audit_address_rule where rule_id='"+bpRuleMappingRuleId+"' and match_exp='"+destination+"' and modified_date>'"+bpRuleMappingDate+"' order by modified_date limit 1"

addressRuleStartTime:
select modified_date from audit_address_rule where rule_id='"+bpRuleMappingRuleId+"' and match_exp='"+destination+"' and modified_date<'"+bpRuleMappingDate+"' order by modified_date desc limit 1"

if(addressRuleEndTime = null)
addressRuleEndTime=addressRuleStartTime


pulseRuleStartTime:
select modified_date from audit_pulse_rule where rule_id='"+addressPulseRuleId+"' and modified_date<'"+addressRuleModifiedDate+"' order by modified_date desc limit 1"

pulseRuleEndTime:
select modified_date from audit_pulse_rule where rule_id='"+addressPulseRuleId+"' and modified_date>'"+addressRuleModifiedDate+"' order by modified_date limit 1;

if(pulseRuleEndTime = null)
pulseRuleEndTime=pulseRuleStartTime




select a.value,b.slab_start,b.slab_end,b.grace_period,b.s tart_pulse,b.start_pulse_rate,b.no_of_start_pulse, b.next_pulse,b.next_pulse_rate,b.min_call_duration ,b.connection_charge from audit_address_rule a,pulse_rule b where a.rule_id=(select rule_id from audit_bp_rule_mapping where bp_seq_no=(select bp_seq_no from audit_calendar_billing where bp_code=(select bp_code from audit_subscriber_master where subscriber_id='"+subscriberId+"' and modified_date between '"+subscriberStartTime+"' and '"+subscriberEndTime+"')and modified_date between '"+calendarBillingStartTime+"' and '"+calendarBillingEndTime+"')and modified_date between '"+bpRuleMappingStartTime+"' and '"+bpRuleMappingEndTime+"')and match_exp="+destination+" and a.pulse_rule_id=b.rule_id and a.modified_date between '"+addressRuleStartTime+'" and '"+addressRuleEndTime+"' and b.modified_time between '"+pulseRuleStartTime+"' and '"+pulseRuleEndTime+"';