By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,514 Members | 1,702 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,514 IT Pros & Developers. It's quick & easy.

selecting XML columns

P: n/a
Xh
Hi All,

I'm using DB2 v9 Express-C - I have problem when selecting XML
columns.

I have 2 columns in patients table:
- id_patient
- patient_info

select * from patients;
select id_patient, patient_info from patients;

work fine - but that's easy ;)

I added new table examinations (1 patient can have many examinations)
examination:
id_examination
id_patient
examination_results

and tried to do something like this, show me patients' ids and infos +
number of examinations:

SELECT P.ID_PATIENT, P.PATIENT_INFO, COUNT(E.ID_EXAMINATION) AS
EXAMINATION#
FROM PATEINTS as P, EXAMINATIONS as E
WHERE P.ID_PATIENT = E.ID_PATIENT
GROUP BY P.ID_PATIENT;

but above query returns an error - P.PATIENT_INFO is not included in
"group by", but when
I added it, there was another error saying that XML cannot be used in
grouping functions

any idea what should I do to fetch pateint_info XML + number of
examinations in one query?
does DB2 supports such things?

I have written query with subquery that produces me expected results
- but I'm wondering whether it can be done faster and in more
beautiful way ;)

thanks in advance for any tips
best regards
R

Feb 23 '07 #1
Share this Question
Share on Google+
1 Reply


P: n/a
XML columns cannot be added in group by clause.

Swami
--------------------------------------

On Feb 24, 3:37 am, "Xh" <lukasz.bud...@komputery-internet.netwrote:
Hi All,

I'm using DB2 v9 Express-C - I have problem when selecting XML
columns.

I have 2 columns in patients table:
- id_patient
- patient_info

select * from patients;
select id_patient, patient_info from patients;

work fine - but that's easy ;)

I added new table examinations (1 patient can have many examinations)
examination:
id_examination
id_patient
examination_results

and tried to do something like this, show me patients' ids and infos +
number of examinations:

SELECT P.ID_PATIENT, P.PATIENT_INFO, COUNT(E.ID_EXAMINATION) AS
EXAMINATION#
FROM PATEINTS as P, EXAMINATIONS as E
WHERE P.ID_PATIENT = E.ID_PATIENT
GROUP BY P.ID_PATIENT;

but above query returns an error - P.PATIENT_INFO is not included in
"group by", but when
I added it, there was another error saying that XML cannot be used in
grouping functions

any idea what should I do to fetch pateint_info XML + number of
examinations in one query?
does DB2 supports such things?

I have written query with subquery that produces me expected results
- but I'm wondering whether it can be done faster and in more
beautiful way ;)

thanks in advance for any tips
best regards
R

Feb 25 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.