473,748 Members | 4,697 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

combining results by unique id

2 New Member
i get a list of results based on an id and based on a status value that can be 'active', 'inprocess' or 'cancel' - it is possible that the same user has both 'active' and 'inprocess' states associated with him and i want to combine the values for this user and show this result as 1 row instead of 2 rows - and I want to concatenate selected values that differ , so something like this - status='Active+ InProcess'

so i currently get something like the results below (the full row has a lot of data - please see full query at end of post):

id status
--------------------------
664 active
664 inprocess
199 cancel
103 active

i would like to get this

id status
--------------------------
664 active+ inprocess => the results for 664 collapsed to a single row
199 cancel
103 active

i can get the results for the id field by using "group by" but only if the id is the only selected field -

so i am able to get this using group by

id
---------
664
199
103

but it is missing the full data

I also looked at 'group by' and 'having' but doesn't quite seem to do it for a large number of selected values - they seem to all need to be in the group by if they are selected which loses the distinctness of just the id - is it some kind of aggregate thing? - any help would be great -

- Thanks!!!

this is the full query

==========
==========
-- the id value is attendeeid

SELECT ah.attendeeid, a.lastname, a.firstname,r.c heckindate,r.ch eckoutdate,
hp.hotelname, h.roomtype, rt.description as roomdesc, r.registrationi d, r.eventid, rt.hotelid,
ah.description, ah.original, a.email, ht.columnname, ah.attendeehist oryid, ah.historytype
FROM registration r, .reservation h,
room_types rt, hotel_profile hp, attendee_histor y ah,
attendee a, history_types ht
WHERE r.eventid=12
AND ah.attendeeid=h .attendeeid
AND ah.attendeeid=a .attendeeid
AND ah.attendeeid=r .attendeeid
AND ah.eventid=h.ev entid
AND ah.eventid=r.ev entid
AND h.roomtype=rt.r oomtype
AND rt.hotelid=hp.h otelid
AND ah.historytype= ht.historytypei d
AND ah.changeproces sed is null
AND h.roomtype is not null
AND ah.historytype in {10,11,21} -- 'active', 'inprocess' or 'canel' changes
AND ah.operation = 'Change'
Jun 7 '07 #1
1 1440
striker77
2 New Member
I'm adding the relevant platform info below.

The query is run against db2.

The db2 server is Express 9.1 Fixpack 2
The platform is Windows Server 2003.
Jun 8 '07 #2

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

Similar topics

5
6064
by: JackT | last post by:
Hi, I have the following SQL SELECT Table1.Col1, Table3.Col1 AS Expr1, COUNT(Table1.Col2) AS Col2_No, COUNT(Table1.Col3) AS Col3_No etc, FROM Table3 INNER JOIN Table2 ON Table3.Col1=Table2.Col1 RIGHT OUTER JOIN Table1 ON Table2.Col2=Table2.Col2 GROUP BY Table1.Col1, Table3.Col1
3
1735
by: alwayswinter | last post by:
I currently have a form where a user can enter results from a genetic test. I also have a pool of summaries that would correspond to different results that a user would enter into the form. I ideally I would like to have the user enter their results and then have a master summary created with the different word or HTML files on submit. (condition 1 + condition 2 = combining/displaying corresponding HTML files) I've gotten as far as...
2
1563
by: Max | last post by:
Hello everyone, I have a task of combining two tables: tblPatient and tblSolution, related by a KEY field in a one-to-many relationship from tbl Patient to tblSolution, respectively. So, I have the following table layout: tblPatient ---------- REC: Autonum (Primary Key) KEY: Number (NOT UNIQUE)
2
2590
by: rdraider | last post by:
Using SQL 2000, how can you combine multiple records into 1? The source data is varchar(255), the destination will be text. I need help with the select statement. example tables: CREATE TABLE ( , , (255), ,
0
8984
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
9363
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
9312
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
9238
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
8237
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...
1
6793
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
6073
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4593
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...
3
2206
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.