Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7722843
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T04:17:30+00:00 2026-06-01T04:17:30+00:00

We have a table like this: id mid mult tr result —————————- 1 1

  • 0

We have a table like this:

id  mid mult    tr  result
----------------------------
1   1   1,35    0   1   
2   1   5,85    0   2   
3   1   4       1   X   
50  2   1,3     1   1   
51  2   7       0   2   
52  2   4       0   X   
99  3   2,45    0   1   
100 3   2,2     0   2   
101 3   3,3     1   X   
105 4   2,3     0   1   
106 4   2,4     0   2   
107 4   3,2     1   X   
111 5   3       1   1   
112 5   1,9     0   2   
113 5   3,25    0   X   

What we need is a query that will bring us a table which will count how many times before, for a specific mid(match), have the same mults(multipliers) for result = 1 and result = x have occurred and group them so that we can count them. Something like

select mult(where result = 1), mult(where result = x), count(1)

The result will be like this

mult_1      mult_x      count
------------------------------
1,35        4           33
1,3         4           112

The above states that we have seen 33 matches where the mult for result = 1 was 1,35 AND mult for result = x was 4. Also, we found 112 matches where multi for result = 1 was 1,3 AND for result = x mult was 4 (results are not dependant on the first table).

I find it rather complex myself, but hopefully I made sense. I use SQL Server 2008, so any method is more than welcome.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T04:17:32+00:00Added an answer on June 1, 2026 at 4:17 am

    Here is my (final) solution in action: http://www.sqlfiddle.com/#!3/3a516/7

    There are a number of assumptions I’m making here.

    • I’m assuming that every mid value is going to have at most 1 result value of '1' and 1 result of '2'.
    • I’m assuming that if you want to specify a mid and have the query run off of that.
      • This assumption turned out to be wrong.
    • I’m assuming that you want to include the data for the mid you specify.
      • This assumption turned out to be wrong, it was every match.
    • I’m assuming that you want to include every mid (or match) before the mid you specify.
      • This assumption turned out to be wrong, it was every match.
    • I’m assuming that for any mult_1 and mult_x combination you find in this way, you want the count of how many times that combination occurs, even if it occurs after the match(mid) that you specified.
      • This assumption turned out to be wrong, it was just for every match.

    If all of these assumptions sound right, then this might create the result you’re looking for:

    DECLARE @Mid INT = 2
    
    ;WITH MatchResults AS
    (
      SELECT
        Mid
        , [1] AS MultWithResult1
        , [X] AS MultWithResultX
      FROM
      (
        SELECT
          Mid
          , mult
          , result
        FROM Matches
        WHERE result IN ('1', 'X')
      ) Base
      PIVOT
      (
        MAX(mult)
        FOR result
        IN
        (
          [1]
          , [X]
        )
      ) Pivoted
    )
    SELECT
      mult.MultWithResult1 AS mult_1
      , mult.MultWithResultX AS mult_x
      , COUNT(*) AS [count]
    FROM MatchResults mult
    GROUP BY mult.MultWithResult1
      , mult.MultWithResultX
    

    EDIT: I have edited it based on the response to my answer to what I think he means.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table like this (Oracle, 10) Account Bookdate Amount 1 20080101 100
I have table like this: Name Result T1 fail T2 pass T3 pass T2
I have table like this : ID Name_1 Name_2 Name_3 1 Egon Spengler Ives
I have a table like this: Application,Program,UsedObject It can have data like this: A,P1,ZZ
I have a Table like this one: |UserId | ContactID | ContactName --------------------------------------- |
I have a table like this: name code group john 12 smith 15 how
I have a table like this... CustomerID DBColumnName Data 1 FirstName Joe 1 MiddleName
i have a table like this one: -------------------------------- id | name -------------------------------- 1 |
I have two table like this table_CN (_id, name, phone, favorite, title) table_EN (_id,
I have a table like this (using wordpress) +---------+----------+------------+ | meta_id | meta_key |

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.