SQL sub statement in a aspx file for c# in visual studio 13 RRS feed

  • Question

  • User-1728156529 posted

    I am struggling again with a sql statement , this time it should count two coulmns and display them , but the sum of this two columns should be displayed as well where the sum of the most top 10 are shown.

    I am building it like this but ofcourse it gives error since my sql is poorly done:

    SelectCommand="SELECT top 10 Finals WHERE EXISTS ,(SELECT [Winner], COUNT(*) Winner1 FROM [Tournament] ), ( SELECT  [Runner], COUNT(*) Runner1 FROM [Tournament]) From [Tournament] AND Winner1+Runner1=Finals GROUP BY Finals "></asp:SqlDataSource>

    I have all five fields above declared as  asp:BoundField DataFields hopefully this should be ok.

    Thanks to all users of this site that have helped me earlier and I am sure its users will help me out once again!

    Merry Christmas and Happy New Year!

    Thursday, December 24, 2015 10:13 AM


All replies

  • User61956409 posted

    Hi stenmananders,

    Firstly, could you show us some your original data and the output you want? Which will help us understand your requirement.

    Secondly, you could refer to this thread that discussed how to count columns and get summary data.


    Best Regards,

    Fei Han

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, December 25, 2015 7:35 AM
  • User-1728156529 posted

    Hi Fei Han,

    The out put should display the amount of times the player are listed in a column, as well display a total of amounts in Col A Col B

    Wins                Loss

    Player 1          Player 2

    Player 1           Player 2

    Player 1          Player 3

    Player 2          Player 1

    Player 3          Player 1

    That should give output:

    Name      Wins       Losses           Total

    Player1    3               2                    5

    Player2    1               3                    4

    Player3    1               1                    2

    Thanks in advance for your help.

    Tuesday, January 5, 2016 11:37 AM
  • User83180098 posted

    Nice solution man!!! i needed to find a way to make this on my website and thanks to asp.net i can do it, seriously im very happy about it, nice updates, im waiting for the next bro!! a hug and goodbye to all ;) this is my website and this is how i did it thanks to all your help guys!! thank u again Abogados Madrid

    Wednesday, January 13, 2016 2:18 PM