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

  • Home
  • SEARCH
  • 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 8020141
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T21:36:11+00:00 2026-06-04T21:36:11+00:00

My data in Database Table … SELECT [Quote Reference Number] ,[Value] ,[Method] ,[Country] ,[SubRegion]

  • 0

My data in Database Table …

SELECT [Quote Reference Number] 
      ,[Value]
      ,[Method]
      ,[Country]
      ,[SubRegion]
      ,[Route 1 or Route2]
      ,[TYPE A or B ]
  FROM Table 1 

My Desired Summary view

WORLD VIEW

Subregion | Country | Count of Route1 + Type A quotes | Count of Route1 + Type B quotes|  Count of Route2 + Type A quotes | Count of Route2 + Type B quotes| All Routes & Types |

EMEA VIEW

Subregion | Country | Count of Route1 + Type A quotes | Count of Route1 + Type B quotes| Count of Route2 + Type A quotes | Count of Route2 + Type B quotes| All Routes & Types |

I could do this by creating a table with 2 rows and just doing lots of sql queries to populate all the fields but was told it could be done by Pivoting in the database but dont know how exactly ?

Can anyone offer some assistance ?

  • 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-04T21:36:12+00:00Added an answer on June 4, 2026 at 9:36 pm

    Pivot in the case would be difficult (but not impossible) because the FOR... IN clauses contains a field and a set of values respectively, not Conditional statements. You’re better of with a sum/case e.g.

    SELECT 
          [Country]
          ,[SubRegion]
          ,SUM (CASE WHEN [Route 1 or Route2] = 'Route1' AND [TYPE A or B ] = 'A' 
                 THEN 1 ELSE 0 END)
                  as [Count of Route1 + Type A quotes ]
          ,SUM (CASE WHEN [Route 1 or Route2] = 'Route1' AND [TYPE A or B ] = 'B' 
                 THEN 1 ELSE 0 END)
                  as [Count of Route1 + Type B quotes ]
         ,SUM (CASE WHEN [Route 1 or Route2] = 'Route2' AND [TYPE A or B ] = 'A' 
                 THEN 1 ELSE 0 END)
                  as [Count of Route2 + Type A quotes ]
          ,SUM (CASE WHEN [Route 1 or Route2] = 'Route2' AND [TYPE A or B ] = 'B' 
                 THEN 1 ELSE 0 END)
                  as [Count of Route2 + Type B quotes]
          ,COUNT(*)  All Routes & Types
      FROM [Table 1]
      GROUP BY
           [Country]
          ,[SubRegion]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to select data from a database table that is not part of
I use this code to update data in database table. Can reuse same code
I'm using LINQ to Get data from database table called table1 when using LINQ
I have an Excel file that gets external data from database table. I need
I am getting some data from my database table. The query I use is
I have to copy a bunch of data from one database table into another.
I am writing an exporting function to take data from a database table and
I'm using a particular database table like a Set data structure, i.e., you can
In a MySQL (5.1) database table there is data that represents: how long a
The situation: I fetch a complete table from my sqllite core data database and

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.