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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T08:07:39+00:00 2026-05-30T08:07:39+00:00

What is the most efficient way to format query results, wether in the actual

  • 0

What is the most efficient way to format query results, wether in the actual SQL Server SQL code or using a different program such as access or excel so that the X (first row column headers) and Y Axis (first column field values) can be changed, but with the same query result data still being represented, just in a different way.

they way the data is stored in my database and they way my original query results are returned in SQL Server 2008 are as follows:

Original Results Format

And Below is the way I need to have the data look:

How I need the Results to Look

In essence, I need to have the zipcode field go down the Y Axis (first column) and the Coveragecode field to go across the top first Row (X Axis) with the exposures filling in the rest of the data.

The only way I can thing of getting this done is by bringing the data into excel and doing a bunch of V-LookUps. I tried using some pivot tables but didn’t get to far. I’m going to continue trying to format the data using the V-LookUps but hopefully someone can come up with a better way of doing this.

  • 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-30T08:07:41+00:00Added an answer on May 30, 2026 at 8:07 am

    What you are looking for is a table operator called PIVOT. Docs: http://msdn.microsoft.com/en-us/library/ms177410.aspx

    WITH Src AS(
        SELECT Coveragecode, Zipcode, EarnedExposers
        FROM yourTable
    )
    SELECT Zipcode, [BI], [PD], [PIP], [UMBI], [COMP], [COLL]
    FROM Src
    PIVOT(MAX(EarnedExposers) FOR CoverageCode 
        IN(
               [BI], 
               [PD], 
               [PIP], 
               [UMBI], 
               [COMP], 
               [COLL]
          )
    ) AS P;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to figure out the most efficient way to format this query.
What is the most efficient way of converting a single column linq query to
What is the quickest most efficient way to search text for words using non-casesensitive
What would anyone consider the most efficient way to merge two datasets using Python?
I was wondering, what is the most efficient way of combining results into a
What is the most efficient way to load a resource using Ajax and then
What's the most efficient way to get the current date in ISO format (e.g.
What is the most efficient way to drop a table in SAS? I have
What is the most efficient way for checking for equality of two m *
What is the most efficient way to set/re-order the TabIndex properties of many form

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.