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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T18:46:15+00:00 2026-05-26T18:46:15+00:00

I am creating a C# application I will explain what I want by giving

  • 0

I am creating a C# application I will explain what I want by giving a simple example:

consider this table:

name   age     reply   choice 
------+-------+-------+-------
John   10-20   yes     apple
Kate   20-30   yes     orange
Sam    10-20   yes     apple
Peter  10-20   no      ----
Tom    20-30   no      ----
Mike   10-20   yes     orange

I would like to put together a predictive “age” decision tree for all the persons who have replied. and then predict the choices of the ones who didn’t reply.

The table is saved in an SQL Server 2008 database. And there is a feature in the SQL Server 2008 that allows to do that. I searched the Microsoft help website but I didn’t find any clear guide on how to use it.

How can I use it in my C# code, Anyone got a step by step guide for it?

  • 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-26T18:46:16+00:00Added an answer on May 26, 2026 at 6:46 pm

    This would do the trick:

    -- create table
        declare @t table (name varchar(50), age varchar(50), reply varchar(3), answer varchar(50))
        insert @t (name, age, reply, answer)
        values ('John', '10-20', 'yes', 'apple'),
        ('Kate', '20-30', 'yes', 'orange'),
        ('Sam', '10-20', 'yes', 'apple'),
        ('Peter', '10-20', 'no', '----'),
        ('Tom', '20-30', 'no', '----'),
        ('Mike', '10-20', 'yes', 'orange')
    
    -- get answer
        select  t.name, t.age, t.reply, case t.reply when 'yes' then t.answer else w.answer end answer
        from    @t t
                left join (
                    select age, answer
                    from (
                        select  age, answer, count(*) cnt, row_number() over (partition by age order by count(*) desc) rnk
                        from    @t
                        where   reply = 'yes' 
                        group by age, answer
                    ) s
                    where rnk = 1
                ) w on t.age = w.age 
    

    Just find out what answer as provided the most for each age and then pick that answer if none was given.

    When there is a tie between 2 answers, it just picks one. I think the one that comes first but the are no guarantees that it will always do that.

    Be aware tho that if you have a group where the answers are A:B = 55%:45%, then all the people with no answer get answer A, so you’d change the averages of the population by doing this. Just so you know.

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

Sidebar

Related Questions

I am creating a windows application using VB.Net and this application will take a
I'm creating an application that will store a hierarchical collection of items in an
I am creating an application that will have a list of items that can
I'm creating an application that will store geolocation data for specific transactions. Should I
I am creating a small application that will be deployed on Window. The database
I am creating a Silverlight application which will be heavily javascripted against. To enable
I'm creating an application where I will be drawing two circles onto the screen,
I'm currently creating an MVC application that will likely to expand to include a
I'm in the process of creating a C# application which will monitor changes made
I am creating an application in java which will be the part of an

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.