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 4601242
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T23:47:50+00:00 2026-05-21T23:47:50+00:00

Database: Transaction ProductID 1 1000 2 1000 2 1001 3 1000 3 1002 4

  • 0

Database:

Transaction  ProductID
 1              1000
 2              1000
 2              1001 
 3              1000
 3              1002
 4              1000
 4              1001
 5              1003

and L1 table (i keep Frequenties item)

PRODUCTID  SUPPORT
  1000       4
  1001       2
  1002       1
  1003       1

According to L1 table, how to find this result with a T-SQL statement? And find support value from my Transaction table?

+-------------+-----------+-----------------+
| PRODUCTID1  | PRODUCTID2|     SUPPORT     |
+-------------+-----------+-----------------+
|      1000   |   1001    |         2       |
+-------------+-----------+-----------------+
|      1000   |   1002    |         1       |
+-------------+-----------+-----------------+
|      1000   |   1003    |         0       |
+-------------+-----------+-----------------+
|      1001   |   1002    |         0       |
+-------------+-----------+-----------------+
|      1001   |   1003    |         0       |
+-------------+-----------+-----------------+
|      1002   |   1003    |         0       |,
+-------------+-----------+-----------------+

Test Table:

create table transactions(
   ORDERID    INT,
   PRODUCTID INT
);

insert into transactions(ORDERID, PRODUCTID)
values ('1', '1000')
      ,('2', '1000')
      ,('2', '1001')
      ,('3', '1000')
      ,('3', '1002')
      ,('4', '1000')
      ,('4', '1001'),
       ('5', '1003');

  CREATE TABLE L1
(PRODUCTID INT,
SUPPORT INT )

 INSERT INTO L1 (PRODUCTID,SUPPORT)
   SELECT PRODUCTID,COUNT(*) [SUPPORT] FROM transactions
                    GROUP BY PRODUCTID                        
                    ORDER BY PRODUCTID

Thanks in advance.

  • 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-05-21T23:47:51+00:00Added an answer on May 21, 2026 at 11:47 pm
    WITH Pairs 
         As (SELECT A.PRODUCTID AS PRODUCTID1, 
                    B.PRODUCTID AS PRODUCTID2 
             FROM   L1 A 
                    JOIN L1 B 
                      ON A.PRODUCTID < B.PRODUCTID) 
    SELECT PRODUCTID1, 
           PRODUCTID2, 
           COUNT(t2.ORDERID) AS SUPPORT
    FROM   Pairs 
           LEFT JOIN transactions t1 
             ON t1.PRODUCTID = PRODUCTID1 
           LEFT JOIN transactions t2 
             ON t2.PRODUCTID = PRODUCTID2 
                AND t1.ORDERID = t2.ORDERID 
    GROUP  BY PRODUCTID1, 
              PRODUCTID2  
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Database: Transaction ProductID 1 1000 2 1000 2 1001 3 1000 3 1002 4
I want to design a database which will keep record for financial transaction.I want
I have a database with a transaction field, this displays products brought on my
I have one table called: Transaction. This table has the following fields: (ID,ProductName,Amount,Date) placed
I have a database consisting of a Customer, Product, and Transaction table. I'm trying
How critical are transaction logs after a full backup of a SQL2005 database? Example:
With sharding, how can you maintain a reliable transaction across multiple database servers? For
I'm looking to design an inventory database that tracks a snack bar. As this
I'm trying to create a table of information in a database query using Zend
Our .LDF (SQL Server Database Transaction Log File) has grown to 45GB over the

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.