473,770 Members | 7,142 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Split multirow resultset to single row, multicolumn resultset

1 New Member
Hello All

I want to Split multirow resultset to single row, multicolumn resultset
my table is
ProfileDetail(P rofileId 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,Prope rtyValue,Row_Nu mber() over( order by ProfileDetail.P rofileId ) as RowId from ProfileDetail (Nolock)) b where b.rowid=2 ) as Lname ,
(select b.PropertyValue from (select ProfileId,Prope rtyValue,Row_Nu mber() over( order by ProfileDetail.P rofileId ) as RowId from ProfileDetail (Nolock)) b where b.rowid=3 ) as Gender ,
(select b.PropertyValue from (select ProfileId,Prope rtyValue,Row_Nu mber() over( order by ProfileDetail.P rofileId ) as RowId from ProfileDetail (Nolock)) b where b.rowid=4 ) as BDate ,
(select b.PropertyValue from (select ProfileId,Prope rtyValue,Row_Nu mber() over( order by ProfileDetail.P rofileId ) as RowId from ProfileDetail (Nolock)) b where b.rowid=5 ) as Zip ,
(select b.PropertyValue from (select ProfileId,Prope rtyValue,Row_Nu mber() over( order by ProfileDetail.P rofileId ) as RowId from ProfileDetail (Nolock)) b where b.rowid=6 ) as Phone ,
(select b.PropertyValue from (select ProfileId,Prope rtyValue,Row_Nu mber() over( order by ProfileDetail.P rofileId ) as RowId from ProfileDetail (Nolock)) b where b.rowid=7 ) as GMTZoneId
from (select ProfileId,Prope rtyValue,Row_Nu mber() over( order by ProfileDetail.P rofileId ) 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 1651

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

Similar topics

9
6782
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 loss as to why MS has designed their tab controls like this.
4
2629
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 goodness of my brain, I cant seem to find it anywhere and just not able to do a "using System.WIndows.form". WHere on earth can I get this work? Please help! I just need a simple multicolumn listbox. Why is this so difficult? :(
1
5056
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 top of the listbox eg. 5, 10, 'Go' As I need multiple rows of data I have a button to 'Load' this to the listbox. I'm stuck though as I'm having difficulty loading this correctly. Question: Woulkd I be better off with a datagrid for this job,...
7
6121
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
2799
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 help. Thank you. Here's the code & error messages: Traceback (most recent call last): File "<pyshell#11>", line 1, in -toplevel- p.split()
3
2182
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 23949495 34945959
5
17764
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... this.listBox3.Items.AddRange(new object { "Item 1, column 1", "Item 2, column 1", "Item 3, column 1",
3
5644
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 treeview. Having done some research it seems there was some rather extensive and laborious methods for achieving such an effect in VB6 but none of them satisfactory and the only method I can find that looks anywhere near like it might possibly be...
7
6836
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 SECTION. EXEC SQL INCLUDE SQLCA END-EXEC EXEC SQL BEGIN DECLARE SECTION
0
9592
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9425
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10230
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10004
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9870
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8886
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5313
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5450
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3576
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.