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
btcexchAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ryan ChongCommented:
you need to tell us what's the original tables from your queries so that we can suggest a solution for you.

also tell us what database you're using as it could have different approaches available
0
Miguel OzSoftware EngineerCommented:
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>

Open in new window

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();

Open in new window

Basically code adds the query results into a  list of strings  that is assigned as grid view data source.
0
btcexchAuthor Commented:
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"

Open in new window

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 "

Open in new window

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'

Open in new window

0
Ryan ChongCommented:
you may try this:

Select a.early, b.Late, c.Excess
from
(
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
) a,
(
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'
) b,
(
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'
) c

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
btcexchAuthor Commented:
Thank you a lot .. Excellent Solution
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.