Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Help Me in Formating Results

Author  Topic 

ganeshkumar08
Posting Yak Master

187 Posts

Posted - 2008-07-24 : 09:19:58
I have Two Table
Table1
(MatchID,MatchName,QCName)
Table2
(MatchID,PlayerName,StartTime,EndTime)

From the above two table My Result Table Must have
----------------------------------------
MatchName | QCName
MatchID|PlayerName|StartTime|EndTime
MatchID|PlayerName|StartTime|EndTime
MatchID|PlayerName|StartTime|EndTime
MatchID|PlayerName|StartTime|EndTime
MatchName | QCName
MatchID|PlayerName|StartTime|EndTime
MatchID|PlayerName|StartTime|EndTime
MatchID|PlayerName|StartTime|EndTime
MatchID|PlayerName|StartTime|EndTime
MatchID|PlayerName|StartTime|EndTime
MatchID|PlayerName|StartTime|EndTime
MatchID|PlayerName|StartTime|EndTime
MatchID|PlayerName|StartTime|EndTime
MatchID|PlayerName|StartTime|EndTime
MatchID|PlayerName|StartTime|EndTime

can i result as above
Thanks
Ganesh


Solutions are easy. Understanding the problem, now, that's the hard part

elancaster
A very urgent SQL Yakette

1208 Posts

Posted - 2008-07-24 : 09:33:41
i'm gonna assume you player name in the group is actually qcname?

select MatchName,QCName,t2.MatchID,PlayerName,StartTime,EndTime
from table1 t1 join table2 t2
on t1.MatchID = t2.MatchID


how you then 'group them' as described in your post is for your presentation layer to worry about

Em
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-07-24 : 09:41:55
quote:
Originally posted by ganeshkumar08

I have Two Table
Table1
(MatchID,MatchName,QCName)
Table2
(MatchID,PlayerName,StartTime,EndTime)

From the above two table My Result Table Must have
----------------------------------------
MatchName | PlayerName
MatchID|PlayerName|StartTime|EndTime
MatchID|PlayerName|StartTime|EndTime
MatchID|PlayerName|StartTime|EndTime
MatchID|PlayerName|StartTime|EndTime
MatchName | PlayerName
MatchID|PlayerName|StartTime|EndTime
MatchID|PlayerName|StartTime|EndTime
MatchID|PlayerName|StartTime|EndTime
MatchID|PlayerName|StartTime|EndTime
MatchID|PlayerName|StartTime|EndTime
MatchID|PlayerName|StartTime|EndTime
MatchID|PlayerName|StartTime|EndTime
MatchID|PlayerName|StartTime|EndTime
MatchID|PlayerName|StartTime|EndTime
MatchID|PlayerName|StartTime|EndTime

can i result as above
Thanks
Ganesh


Solutions are easy. Understanding the problem, now, that's the hard part


The format is something that you need to do at your front end. you just need to retrive the records as a complete set and then do formatting from it. Whats the front end you're using?
Go to Top of Page

ganeshkumar08
Posting Yak Master

187 Posts

Posted - 2008-07-24 : 09:43:13
No Need grouping here, Directly we need to match the MatchID column from both tables and have to format the Results as above specified

Solutions are easy. Understanding the problem, now, that's the hard part
Go to Top of Page

ganeshkumar08
Posting Yak Master

187 Posts

Posted - 2008-07-24 : 09:43:49
i am using C#

Solutions are easy. Understanding the problem, now, that's the hard part
And small modification, Instead of QC name i gave there Playername.
My result should be like this.
MatchName | QC Name
MatchName PlayerName StartTime EndTime
Go to Top of Page

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2008-07-24 : 10:28:28
Where are you outputting the data? Using C# doesn't tell us how you eventually are creating the output. That is where you do your grouping.

- Jeff
http://weblogs.sqlteam.com/JeffS
Go to Top of Page

MakeYourDaddyProud

184 Posts

Posted - 2008-07-24 : 11:37:00
It is never the responsibility to mangle data on the presentation layer.

Your SQL has to appear in a Stored Procedure as two SQLs

create procedure matchresult
...
SELECT MatchName, 1 QCName
...
SELECT MatchName, 2, PlayerName StartTime EndTime

RETURN

You will then need to implement Sorting in your C# disconnected ADO.Net DataSet object (do not use a DataAdapter Cursor). Look for a Sort() method using COLUMN 1 and 2. This will give you Match header and player detail pairs which can then be presented to the Presentation Layer in one dataset to your presentation layer via Binded Server controls.

I wont go into much more detail than that becuase this is really an SQL forum.

Are you good enough? Skillprover.com
Go to Top of Page
   

- Advertisement -