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.
Author |
Topic |
aaroniac
Starting Member
2 Posts |
Posted - 2007-01-18 : 14:15:23
|
I have a table which contains a sports schedule:team1_id,team2_id,result1,result2result1 is for team1_idresult2 is for team2_idI want to run a query to get summarize the two id fields with their assoiciated results:For Example the dataset might look like this:row 1 - id1=20,id2=30,result1=1,result2=3row 2 - id1=30,id2=20,result1=2,result2=2row 3 - id1=20,id2=40,result1=3,result2=1row 4 - id1=40,id2=20,result1=1,result2=3how do I build the query to merge the ids and thier respective results into one countable dataset |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-01-18 : 14:34:17
|
Hard to tell without some sample data that builds up the expected output you provided.Peter LarssonHelsingborg, Sweden |
|
|
aaroniac
Starting Member
2 Posts |
Posted - 2007-01-18 : 15:04:30
|
Here is some data - the result1 goes with the id1 and the result2 goes with the id2 - the ids with the same numbers are the same team just in different columns with their own respective result. I need the output to be just two columns - id and result. then I can push the data into a pivot query which I already have working.id1 id2 result1 result252 22 1 223 24 2 225 26 1 327 28 3 129 30 2 130 28 1 129 27 4 226 24 2 325 23 1 322 52 2 152 23 3 322 24 2 125 27 3 326 28 1 229 30 1 130 27 1 129 28 1 226 23 2 325 24 1 122 52 3 352 24 1 222 23 1 125 28 2 126 27 3 129 30 3 230 26 2 329 25 1 328 24 2 227 23 2 122 52 2 152 25 1 322 26 2 223 28 3 124 27 1 329 30 2 2 |
|
|
jsmith8858
Dr. Cross Join
7423 Posts |
Posted - 2007-01-18 : 15:46:29
|
select id1, result1 from yourtableunion allselect id2, result2from yourtable- Jeff |
|
|
|
|
|
|
|