I don't have any idea to create this sorry if it is a silly question.
I have a table two teams and total watch and I will use this information later a different place so my idea concat this two column in one column but two different rows:
HomeTeam AwayTeam Totalwatch
A B 100
A C 90
C A 80
D B 70
C E 50
Can I this
Teams TotalWatch
A 100
B 100
A 90
C 90
C 80
A 80
D 70
B 70
C 50
E 50
I have a few columns so they will repeat as well.
Just a note I know how can concat in one-row use with concat function I do not know how can I make with two rows
You can use UNION ALL and an ORDER BY Totalwatch DESC to get the results ordered according to Totalwatch.
SELECT HomeTeam AS Teams, Totalwatch FROM YourTable
UNION ALL
SELECT AwayTeam, Totalwatch FROM YourTable
ORDER BY Totalwatch DESC;
Simply use UNION ALL:
SELECT *
FROM(
SELECT HomeTeam Teams,TotalWatch FROM Your_Table
UNION ALL
SELECT AwayTeam,TotalWatch FROM Your_Table
)D
ORDER BY TotalWatch DESC
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With