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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T02:38:59+00:00 2026-06-10T02:38:59+00:00

I have a table with two columns. A foreign key identifier and a XML

  • 0

I have a table with two columns. A foreign key identifier and a XML column. The XML column contains details about the foreign object. If for example my table contains the following:

1 | <details><software name="iTunes" /></details>
1 | <details><software name="iPhoto" /><software name="iTunes" /></details>
2 | <details><software name="iTunes" /><software name="MSSQL" /></details>
2 | <details><software name="Visual Studios" /></details>

How can I run a query that will get me the unique count of ‘software’ per entity? So for example, the expected results would be:

1 | 2
2 | 3

Where column 1 is the identifier and column two is the unique sum.

The closest I have been able to get is the following query:

SELECT
  DISTINCT
  id,
  details.value('count(/details/software)', 'int') AS SoftwareCount
FROM
  detailsTable

But its no where’s near useful. (It shows a unique row for every count it finds).

  • 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-10T02:39:00+00:00Added an answer on June 10, 2026 at 2:39 am
    select 
        id,
        COUNT(distinct( x.sw.value('@name','varchar(50)')))
    from
        detailstable
    cross apply
        detailstable.details.nodes('/details/software') x(sw)
    group by id
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Should a database table that contains two columns that are foreign keys have a
I have two tables linked by a foreign key. Example: CREATE TABLE one (id
I have a table, tblNoComp, that has two columns, both foreign keys pointing to
I have a table with two columns: column A column B 1 2 1
I have a table with a few thousand rows. The table contains two columns,
I have to map two simple table with a foreign key relationship. One of
I'm trying to create a foreign key on two columns of a table to
I have a table that has a primary key consisting of two columns (product_id,
Suppose the table with two columns: ParentEntityId int foreign key Number int ParentEntityId is
I have table with two columns (varchar from, varchar to). This table represents connections

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.