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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T18:43:56+00:00 2026-05-31T18:43:56+00:00

I have TWO tables 1) column 2) row COLUMN TABLE COLumnID —————- 1 2

  • 0

I have TWO tables

1) column

2) row

COLUMN TABLE                
COLumnID
----------------
1
2
3
4
5
6
7
8
9

ROW TABLE
ROW iD
-------------
100
104
101
99
77
20
10

The final output should look like this:

01.Row         1    2    3    4    5    6    7    8    9
02.----------- ---- ---- ---- ---- ---- ---- ---- ---- ----
03.10          x    x              x                  
04.20          x    x         x    x                  
05.77          x                             x        
06.99          x         x                             x
07.100         x    x         x    x                  
08.101         x                                      
09.104         x    x         x                   x

The challenge is to mark a coordinate, with a value of X, if and only if the row value is divisible by the col value, i.e. it has a modulo of zero. The additional requirements are: the final query must work with random row values and the pivot operator should be used.

  • 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-31T18:43:57+00:00Added an answer on May 31, 2026 at 6:43 pm

    The following should do what you are looking for in sql server.
    use a CTE to determine where the x should be and then pivot from that CTE

    with mq as(select a.rowid
                    ,b.columnid
                    ,case when (a.rowid % b.columnid) = 0 then 'X' else null end as coord
               from row_table a
                    inner join column_table b on 1=1)
    
    select  rowid,[1], [2], [3], [4],[5], [6], [7], [8], [9]
    from mq
    pivot( max(coord) for columnid in ([1], [2], [3], [4],[5], [6], [7], [8], [9])) as pv
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table with two columns and one row, and 100% width across
I have two tables with similar columns - let's say table A with column
I have two tables one has a three column composite key. The other needs
I have two tables: object that has object_id column and avalues that have object_id
We have two tables in our application that both have a ShowOrder column. We
Hi I want to have two tables each have an INT id column which
I have two tables, events and photos, which relate together via the 'Event_ID' column.
I have two or more tables which hold values under the same column name.
I have two mysql tables, one needs to start its auto-increment column id with
Suppose I have two tables, table A and table B, and that table A

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.