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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T23:51:55+00:00 2026-05-24T23:51:55+00:00

I tried looking for this question, but found nothing relevant. So here goes… I

  • 0

I tried looking for this question, but found nothing relevant. So here goes…

I have three tables, the extremely simplified versions of which are:

Practitioners:

  • practitioner_id :: int
  • name :: nvarchar

Insurances:

  • insurance_id :: int
  • name :: nvarchar

InsuranceLink:

  • practitioner_id :: int
  • insurance_id :: int

So, the practitioner table contains a list of practitioners, the insurance table contains a list of insurances, and the link table represents which practitioner supports which insurance.

Now, I need to create a view which can display the information like this:

ViewTable:

  • practitioner_id :: int
  • practitioner_name :: nvarchar
  • insurance_1 :: bit
  • insurance_2 :: bit
    …..
  • insurance_100 :: bit

In other words, the columns in the view are the ID and name of the practitioner, and every insurance that exists in Insurances (with the insurance name as the column name (there is an enforced condition that insurance names are unique)). The cells in the insurance columns will indicate if that practitioner supports that insurance.

Is there any way of doing this?

Or better yet, is it possible to use an excel-style pivot table on a DataSet in a VB.NET form? That would also solve many of my problems.

  • 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-24T23:51:56+00:00Added an answer on May 24, 2026 at 11:51 pm

    PIVOT is the keyword you’re looking for.

    select * from 
       (select 
            practitioner_id, 
            practitioner_name, 
            insurance_name
        from practitioner p
        join insurancelink il on p.practitioner_id = il.practitioner_id
        join insurance i on il.insurance_id = i.insurance_id
       )
    pivot (count(*) for insurance_name in ([insurancename1],[insurancename2], ..., [insurancename100]))
    

    I know that now you’re wondering if there’s any way to avoid listing out all the insurance names/having it not be a constant list. The answer is no, pretty much. You can create the view programatically but the view is still going to need to be updated when an insurance is added.

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

Sidebar

Related Questions

I know this is a probable open ended question, and I have tried looking
Looking through StackOverflow this question seems to be asked a lot, but I have
This question has been asked more than once before, but I have not found
I've tried to find a way to do this, but without success. I'm looking
I know silly question but i tried looking it up on Google with no
I have already posted another question about this, but no one seemed to know
This question is a continuation of Malloc call crashing, but works elsewhere I tried
I found (after another question here on StackOverflow) this interesting library written in Python
I've seen that this question has been posted a couple of times but nothing
This is a fairly involved bug, and I've tried looking around to find other

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.