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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T14:45:18+00:00 2026-06-11T14:45:18+00:00

I have a large table with sales data, useful data below: RowID Date Customer

  • 0

I have a large table with sales data, useful data below:

RowID   Date        Customer  Salesperson   Product_Type    Manufacturer   Quantity   Value
1       01-06-2004  James     Ian           Taps            Tap Ltd        200        £850
2       02-06-2004  Apple     Fran          Hats            Hats Inc       30         £350
3       04-06-2004  James     Lawrence      Pencils         ABC Ltd        2000       £980
...
Many rows later...
...
185352  03-09-2012  Apple     Ian           Washers         Tap Ltd        600        £80

I need to calculate a large set of targets from table containing values different types, target table is under my control and so far is like:

TargetID  Year   Month    Salesperson    Target_Type   Quantity
1         2012   7        Ian            1             6000
2         2012   8        James          2             2000
3         2012   9        Ian            2             6500

At present I am working out target types using a view of the first table which has a lot of extra columns:

    SELECT YEAR(Date)
         , MONTH(Date)
         , Salesperson
         , Quantity
         , CASE WHEN Manufacturer IN ('Tap Ltd','Hats Inc') AND Product_Type = 'Hats' THEN True ELSE False END AS IsType1
         , CASE WHEN Manufacturer = 'Hats Inc' AND Product_Type IN ('Hats','Coats') THEN True ELSE False END AS IsType2
    ...
    ...
         , CASE WHEN Manufacturer IN ('Tap Ltd','Hats Inc') AND Product_Type = 'Hats' THEN True ELSE False END AS IsType24
         , CASE WHEN Manufacturer IN ('Tap Ltd','Hats Inc') AND Product_Type = 'Hats' THEN True ELSE False END AS IsType25
FROM SalesTable
WHERE [some stuff here]

This is horrible to read/debug and I hate it!!

I’ve tried a few different ways of simplifying this but have been unable to get it to work.
The closest I have come is to have a third table holding the definition of the types with the values for each field and the type number, this can be joined to the tables to give me the full values but I can’t work out a way to cope with multiple values for each field.

Finally the question:

Is there a standard way this can be done or an easier/neater method other than one column for each type of target?

I know this is a complex problem so if anything is unclear please let me know.

Edit – What I need to get:

At the very end of the process I need to have targets displayed with actual sales:

Type    Year    Month   Salesperson   TargetQty   ActualQty
2       2012    8       James         2000        2809
2       2012    9       Ian           6500        6251

Each row of the sales table could potentially satisfy 8 of the types.

Some more points:

  1. I have 5 different columns that need to be defined against the targets (or set to NULL to include any value)
  2. I have between 30 and 40 different types that need to be defined, several of the columns could contain as many as 10 different values

For point 2, if I am using a row for each permutation of values, 2 columns with 10 values each would give me 100 rows for each sales person for each month which is a lot but if this is the only way to define multiple values I will have to do this.

Sorry if this makes no sense!

  • 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-11T14:45:19+00:00Added an answer on June 11, 2026 at 2:45 pm

    If I am correct that the “Target_Type” field in the Target Table is based on the Manufacturer and the Product_Type, then you can create a TargetType table that looks like what’s below and JOIN on Manufacturer and the Product_Type to get your Target_Type_Value:

    ID   Product_Type    Manufacturer   Target_Type_Value
    1    Taps            Tap Ltd        1
    2    Hats            Hats Inc       2
    3    Coats           Hats Inc       2
    4    Hats            Caps Inc       3
    5    Pencils         ABC Ltd        6
    

    This should address the “multiple values for each field” problem by having a row for each possibility.

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

Sidebar

Related Questions

I have a large table of data (that displays test data) that is separated
I have a table. A large table with 25 columns each containing atomic data
I have a large table of data roughly laid out as follows. As requested
I have sales global sales data in very large files which I need to
I have a large table with the following fields: Date Product_ID AmountEUR_Field1 AmountEUR_Field2 AmountEUR_Field3
I have a large table containing some 15 million row, all varchar data. I
I have large table, with around 200 fields. Around a 100 of those fields
I have large database table, approximately 5GB, now I wan to getCurrentSnapshot of Database
I have a large table with around half a million rows which is taking
I have a large table (between 74 and 88million rows) which is the middle

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.