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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T23:13:10+00:00 2026-06-11T23:13:10+00:00

I have a dimensions table @dimensions Dateid Rep Mkt Prodgroup 201111 002 S 001

  • 0

I have a dimensions table

@dimensions
Dateid  Rep Mkt Prodgroup
201111  002 S   001
201111  002 R   001
201111  002 S   002
201111  002 R   002
201111  002 S   003
201111  002 R   003
201111  002 S   004
201111  002 R   004
...

I want to join it with this table to include the percentage.

@percentageincrease
Prodgroup   Mkt Percent
ALL         S   1.05
ALL         R   1.06
002         S   1.07
002         R   1.08
003         S   1.09
003         R   1.10

I want to join them on Mkt and Prodgroup where @dimensions.Prodgroup IN @percentageincrease.Prodgroup and if not in then to join on the ALL. So the output table would be

Dateid  Rep Mkt Prodgroup   Percent
201111  002 S   001         1.05 // joined on ALL
201111  002 R   001         1.06 // joined on ALL
201111  002 S   002         1.07 // joined on 002
201111  002 R   002         1.08 // joined on 002
201111  002 S   003         1.09 // joined on 003
201111  002 R   003         1.10 // joined on 003
201111  002 S   004         1.05 // joined on ALL
201111  002 R   004         1.06 // joined on ALL
...

As my join condition I have tried

on case p.Prodgroup 
    when N'ALL' 
    then d.prodgrpid 
    else p.Prodgrpid = d.prodgrpid
AND p.Mkt = d.Mkt

but it gave me

Dateid  Rep Mkt Prodgroup   Percent
201111  002 S   001         1.05
201111  002 R   001         1.06
201111  002 S   002         1.07
201111  002 R   002         1.08
201111  002 S   002         1.05 //Joined on ALL
201111  002 R   002         1.06 //Joined on ALL
201111  002 S   003         1.09
201111  002 R   003         1.10
201111  002 S   003         1.05 //Joined on ALL
201111  002 R   003         1.06 //Joined on ALL
201111  002 S   004         1.05
201111  002 R   004         1.06
...

where the tuples which were in the @percentageincrease table were also joined on the ALL condition.

This is being run on SQL Server 2008 as a stored procedure as part of a larger query.

  • 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-11T23:13:11+00:00Added an answer on June 11, 2026 at 11:13 pm

    Assuming the table structures

    declare @dimensions table 
        (Dateid varchar(10),  Rep varchar(10), Mkt varchar(10),Prodgroup varchar(10))
    declare @percentageincrease table 
        (Prodgroup varchar(10),  Mkt varchar(10), [Percent] decimal(9,5))
    

    then

    select 
         d.*, 
         isnull(pinc.[Percent], pincall.[Percent]) 
    from @dimensions d
        left join @percentageincrease pinc 
            on d.Mkt = pinc.Mkt
          and d.Prodgroup = pinc.Prodgroup
        left join @percentageincrease pincall
            on d.Mkt = pincall.Mkt
          and pincall.Prodgroup ='all'  
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this wonderful iFrame that has wonkey dimensions that I want to change
I have a array of two dimensions object[,] data; . I want to convert
i have this : npoints=10 vectorpoint=random.uniform(-1,1,[1,2]) experiment=random.uniform(-1,1,[npoints,2]) and now i want to create an
I have a background div with set dimensions, which includes a table element. I'm
Im looking to have MySQL handle Slowly changing dimensions The table is set up
I have this code in Mathematica: nxBin = Table[{-5 sX + (i - 0.5)*step,
I have set up a nice table with fixed height and weight like this:
I have an OLTP database. For this database, I want to use SQL 2008
I have a large dataframe and want to tabulate all variable-paris. table() and xtabs()
If I want to traverse a quadtree, do the dimensions have to be only

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.