Question

Locked

Union of two queries using vb6.0 coding

By srbatcha ·
i have two query:

#1. Year wise Report:

rec.Open "select Sales_Person_ID,Employee_Name,sum(Total_value),div ision_name,segment_name from segment_trans where (segment_trans.date >= #" & (fdate.Text) & "# and segment_trans.date<= #" & (tdate.Text) & "# ) GROUP BY Sales_Person_ID ,Employee_Name,division_name,segment_name order by division_name,segment_name", con, adOpenKeyset, adLockOptimistic

#2. Month wise Report:

rec1.Open "select Sales_Person_ID,Employee_Name,sum(Total_value),div ision_name,segment_name from segment_trans where (segment_trans.date >= #" & (Text3.Text) & "# and segment_trans.date<= #" & (Text4.Text) & "# ) GROUP BY Sales_Person_ID ,Employee_Name,division_name,segment_name order by division_name,segment_name", con, adOpenKeyset, adLockOptimistic


How to connect this two Queries with in one Query?


please help me.


Thanks
sathik

This conversation is currently closed to new comments.

1 total post (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Answers

Collapse -

With SQL

by Tony Hopkinson In reply to Union of two queries usin ...

SElect * From (
select
Sales_Person_ID,
Employee_Name,
sum(Total_value) as Total_Value,
division_name,
segment_name
from segment_trans
where (segment_trans.date >= #" & (fdate.Text) & "# and segment_trans.date<= #" & (tdate.Text) & "# )
GROUP BY Sales_Person_ID ,Employee_Name,division_name,segment_name
UNIONALL
select
Sales_Person_ID,
Employee_Name,
sum(Total_value),
division_name,
segment_name
from segment_trans where (segment_trans.date >= #" & (Text3.Text) & "# and segment_trans.date<= #" & (Text4.Text) & "# )
GROUP BY Sales_Person_ID ,Employee_Name,division_name,segment_name
) dummyname
order by division_name,segment_name"

Back to Web Development Forum
1 total post (Page 1 of 1)  

Related Forums