473,386 Members | 1,630 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Split multirow resultset to single row, multicolumn resultset

Hello All

I want to Split multirow resultset to single row, multicolumn resultset
my table is
ProfileDetail(ProfileId bigint, PropertyId bigint PropertyValue nvarchar(400))

Table data :

ProfileId PropertyId PropertyValue
97 1 lokendra
97 2 bhatt
97 3 m
97 4 Oct 23 1987 12:00AM
97 5 2344
97 6 535324
97 7 1
97 8 1
97 9 xyz
97 10 0

I put a Query to retrive data from multiple row to single row :

select b.PropertyValue as FName,
(select b.PropertyValue from (select ProfileId,PropertyValue,Row_Number() over( order by ProfileDetail.ProfileId ) as RowId from ProfileDetail (Nolock)) b where b.rowid=2 ) as Lname ,
(select b.PropertyValue from (select ProfileId,PropertyValue,Row_Number() over( order by ProfileDetail.ProfileId ) as RowId from ProfileDetail (Nolock)) b where b.rowid=3 ) as Gender ,
(select b.PropertyValue from (select ProfileId,PropertyValue,Row_Number() over( order by ProfileDetail.ProfileId ) as RowId from ProfileDetail (Nolock)) b where b.rowid=4 ) as BDate ,
(select b.PropertyValue from (select ProfileId,PropertyValue,Row_Number() over( order by ProfileDetail.ProfileId ) as RowId from ProfileDetail (Nolock)) b where b.rowid=5 ) as Zip ,
(select b.PropertyValue from (select ProfileId,PropertyValue,Row_Number() over( order by ProfileDetail.ProfileId ) as RowId from ProfileDetail (Nolock)) b where b.rowid=6 ) as Phone ,
(select b.PropertyValue from (select ProfileId,PropertyValue,Row_Number() over( order by ProfileDetail.ProfileId ) as RowId from ProfileDetail (Nolock)) b where b.rowid=7 ) as GMTZoneId
from (select ProfileId,PropertyValue,Row_Number() over( order by ProfileDetail.ProfileId ) as RowId
from ProfileDetail (Nolock) where ProfileID=97) b where RowId=1

it return the required result
ouput :
Fname Lname Gender Bdate Zip Phone GmtZoneId
hdg bhatt m Oct 23 1987 535324 1


Question : What I need to tune the above query so that it can give me faster result or any idea to get the same result set with different query


Thnks
Lokendra
Mar 28 '07 #1
0 1620

Sign in to post your reply or Sign up for a free account.

Similar topics

9
by: Wayne | last post by:
Is there a way to stop the default action of a multirow tab control whereby the row with focus moves to the front of the tabs? I find this behaviour annoying and confusing to the user and am at a...
4
by: kackson | last post by:
Hi. I attempted to create a multicolumn listbox for my web based aspx application. I search the net, all I get is something like listview or I need to have system.windwos.form. But for the...
1
by: zoneal | last post by:
Hi I have a form with a listbox, two comboboxes and two Radiobuttons. What I want to do is make a selection from both comboboxes and either Radiobutton and display these three elements across the...
7
by: Paul Bromley | last post by:
How can I use this please - I need 2 columns. I have been having difficulty finding info on this and the 2005 Treeview control today. Many thanks for any links or info, Paul Bromley
3
by: Tempo | last post by:
Hey. I am trying to grab the prices from the string below but I get a few errors when I try to do it: Take a look at the code and error messages below for me and thanks you in advanced to all that...
3
by: Augustin Prasanna | last post by:
I need to display some 200 records (dynamic) on the screen.. I need to display records from 2 tables (one to many relationship) output would look like Customer Id Name Phone NO 1 abc ...
5
by: WRH | last post by:
Hello I want to have a multicolumn listbox. I never used one before so I looked at a Help example. I set the multicolumn property and the column width and tested with this example... ...
3
balabaster
by: balabaster | last post by:
Hey guys and gals, I'm not sure if this is the simplest way to do this or if someone can throw any other ideas out there. I'm looking to build a treeview inside a listbox...or have a multicolumn...
7
by: Frank Swarbrick | last post by:
Is there a way to do a multi-row fetch in to a COBOL table with DB2/LUW? Apparently the following is supported in z/OS, but not LUW (or at least I couldn't get it to work): WORKING-STORAGE...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.