473,908 Members | 4,845 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Result Row


Dear All,

Can we do multiple result row as a single row while selection ..?

Request you to provide the SQL if we can achieve this...

For Eg,

Table Name = Employee
id - EmployeeName - addresstype - address1 - address2 - City
1 - AAA - permanent - 231 - First Street - XYA
2 - AAA - Temporary - 343 - Second Street - XYA

Expecting Result as a Single row as below,

id - EmployeeName - Address1 - Address2
1 - AAA - 231/First Street/XYA - 343/Second Street/XYA

Thanks in advance

Rgds,
Ganapathi sundaram.G
Mar 12 '08 #1
1 1340
Ganapathi sundaram wrote:
Can we do multiple result row as a single row while selection ..?

Request you to provide the SQL if we can achieve this...

For Eg,

Table Name = Employee
id - EmployeeName - addresstype - address1 - address2 - City
1 - AAA - permanent - 231 - First Street - XYA
2 - AAA - Temporary - 343 - Second Street - XYA

Expecting Result as a Single row as below,

id - EmployeeName - Address1 - Address2
1 - AAA - 231/First Street/XYA - 343/Second Street/XYA
If each employee will have at most two addresses (permanent and
temporary), then this should work:

select
id,
max(EmployeeNam e) EmployeeName,
max(case addresstype
when 'permanent' then address1 + '/' + address2 + '/' + city
end) Address1,
max(case addresstype
when 'temporary' then address1 + '/' + address2 + '/' + city
end) Address2
from Employee
group by id
Mar 12 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
3680
by: jerrygarciuh | last post by:
Hi all, I am iterating through a result set to generate a second set of queries but no matter what I do I get the error Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource even though if I echo the query to the browser and cut and paste it into the command line I get valid results.
2
1962
by: maceo | last post by:
I have a script that will print out the results of a table and make a calculation of a total of one of the columns. See example: <?php /* Database connection */ include(MYSQL_CONNECT_INCLUDE); /* Select all pilots */ $query = "SELECT * FROM pilots ORDER BY pilot_num ASC";
4
14634
by: John Davis | last post by:
<html> <body> <Form action="calc.asp" method="post" name="calc"> <P>NUM1: <input type="text" name="num1"> <P>NUM2: <input type="text" name="num2"> <P>RESULT: <input type="text" name="result"> <P><input type="submit"> </Form> I want to write an ASP page to accept 2 numbers, and return the sum on the
2
2373
by: swhite76 | last post by:
I have a section of code that adds some double values and gives an incorrect result. This occurs with data that isn't really waht I would call high precision. An example is the following code snippet: --------------- double a = 2.7; double b = 2.7; double c = 0.001; double result=0;
4
1930
by: Tao Wang | last post by:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi, I am quite confused on a equation, as following: #include <iostream> int main(){ int i = 2;
3
3846
by: Michael C# | last post by:
Hi all, I'm sending a command via SqlClient, and it returns two result sets. I can successfully read the first result set, but how can I access the second result set? Here's an example of my SqlCommand CommandText: DECLARE @result AS INT\nEXEC @result = master..xp_cmdshell 'dir "c:\*.*" /b /a-d'\nSELECT @result When run on SQL Server, as
12
2208
by: Mick_fae_Glesga | last post by:
OK, the solution to this is probably blindingly obvious to everyone, but... surely it can't be right. I am compiling with borland bcc32 free compiler this piece of code is designed to identify the most significant bit in a given element in an array of unsigned longs. Now I realise there may be a more efficient way to do this, and if you know a better way please let me know.
9
7441
by: Petr Vileta | last post by:
Hi, I'm new here and excuse me if this question was be here earlier. I have a simple code <html><body> <?php <?php $link = mysql_connect("localhost", "user", "password") or die("Grr: " . mysql_error()); mysql_select_db("my_dbf") or die("Grr");
9
2565
by: JRough | last post by:
I tried to pass the $result from a mysql_query in a url like this line Header("Location:clm_historyXL.php?_result=".$result); but on the redirect location clm_history.php page I get an error on this line: $result = $_POST; I need the $result on the clm_historyXL page to print a list to excel because of a header already being sent.
3
2186
by: JRough | last post by:
I want to save two variables in a $_SESSION for use in another page: $_SESSION = $mark; $_SESSION = $num; then on the other page I did this to get the value: $mark =$_SESSION; $num = $_SESSION;
0
9875
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
11334
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...
0
10911
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
11033
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
10529
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...
1
8092
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5927
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...
1
4762
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3352
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.