btcexch
asked on
how to Combine result from 3 Separate query in one gridview
how to Combine result from 3 Separate query in one gridview in C# And ASP.net
Example:
query1 result: 03:04
query2 result: 12:45
query3 result: 04:13
Gridview
query1 |query2 |query3
03:04|12:45|04:13
Example:
query1 result: 03:04
query2 result: 12:45
query3 result: 04:13
Gridview
query1 |query2 |query3
03:04|12:45|04:13
One possible solution showing results as rows:
<asp:GridView ID="gv" runat="server" AutoGenerateColumns="false">
<Columns>
<asp:BoundField DataField="result" HeaderText="Result" />
</Columns>
</asp:GridView>
var ls=new List<string>();
ls.Add("03:04"); //query1
ls.Add("12:45"); //query2
ls.Add("04:13 "); //query3
gv.DataSource=ls.Select (l =>new{result=l});
gv.DataBind();
Basically code adds the query results into a list of strings that is assigned as grid view data source.
ASKER
Ryan Chong : my database Mysql
select SEC_TO_TIME(sum(TIMESTAMPDIFF(second,reports.inone,date_FORMAT(reports.inone,'%Y-%m-%d 08:00:00') ))) AS early FROM `wave`.`reports` where personnelnr = 12793 and reportdate between '2015/09/01' and '2015/09/30' and date_FORMAT(reports.inone, '%T') < '08:00:00' and time_to_sec(reports.inone) < 28200"
SELECt SEC_TO_TIME( sum(TIME_TO_SEC(reports.lateone ))) AS Late FROM `wave`.`reports` where personnelnr = 12793 and reportdate between '2015/09/01' and '2015/09/30' and reports.lateone >= '00:10:00' Order by personnelnr "
select personnelnr,SEC_TO_TIME( sum(TIME_TO_SEC(reports.otone))) AS Excess FROM `wave`.`reports` where personnelnr=12793 and reportdate between '2015/09/01' and '2015/09/30'and reports.otone >= '00:10:00'
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you a lot .. Excellent Solution
also tell us what database you're using as it could have different approaches available