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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T10:34:15+00:00 2026-06-13T10:34:15+00:00

I have a table for Profiles stores profile properties values in row style, ex:

  • 0

I have a table for Profiles stores profile properties values in row style, ex:

[ProfileID]     [PropertyDefinitionID]      [PropertyValue]
1               6                           Jone
1               7                           Smith
1               8                           Mr
1               3                           50000

and another table for property definitions :

[PropertyDefinitionID]  [PropertyName]
6                       FirstName
7                       LastName
8                       Prefix
3                       Salary

How to use PIVOT or any other way to show it in this way:

[ProfileID] [FirstName] [LastName]  [Salary]
1           Jone        Smith       5000
  • 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-13T10:34:17+00:00Added an answer on June 13, 2026 at 10:34 am

    It’s easy to do this without PIVOT keyword, just by grouping

    select
        P.ProfileID,
        min(case when PD.PropertyName = 'FirstName' then P.PropertyValue else null end) as FirstName,
        min(case when PD.PropertyName = 'LastName' then P.PropertyValue else null end) as LastName,
        min(case when PD.PropertyName = 'Salary' then P.PropertyValue else null end) as Salary
    from Profiles as P
        left outer join PropertyDefinitions as PD on PD.PropertyDefinitionID = P.PropertyDefinitionID
    group by P.ProfileID
    

    you can also do this with PIVOT keyword

    select
        *
    from
    (
        select P.ProfileID, P.PropertyValue, PD.PropertyName
        from Profiles as P
            left outer join PropertyDefinitions as PD on PD.PropertyDefinitionID = P.PropertyDefinitionID
    ) as P
        pivot
        (
            min(P.PropertyValue)
            for P.PropertyName in ([FirstName], [LastName], [Salary])
        ) as PIV
    

    UPDATE: For dynamic number of properties – take a look at Increment value in SQL SELECT statement

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

Sidebar

Related Questions

I have two tables one is table Profile and other is table Profile_location (stores
I have a table that has account numbers in (account_num) and user profiles (profile_id).
using php and mysql I have two tables, a users table and a profiles
I have a table that contains multiple dropdown menus for a list of profile
I have a table which stores comments, the comment can either come from another
Suppose I have an entity class that stores a username: class Profile { private
I have this table for users that stores their usernames and other data, thats
I have a table User that stores user information - such as name, date
1) I have two tables: Photos table and EXIF table. EXIF table stores the
We have an application which stores its data in SQL Server. Each table has

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.