|
Select PZRQTP, sum(case when PZSTAT = 'C' Then COUNT else 0 end) as C_COUNT,
sum(case when PZSTAT = 'I' Then COUNT else 0 end) as I_COUNT,
sum(case when PZSTAT = 'N' Then COUNT else 0 end) as N_COUNT
>From xxxxx
Eric DeLong
Sally Beauty Company
MIS-Project Manager (BSG)
940-898-7863 or ext. 1863
-----Original Message-----
From: MEovino@xxxxxxxxxxxxxxxxx [mailto:MEovino@xxxxxxxxxxxxxxxxx]
Sent: Tuesday, September 16, 2003 1:29 AM
To: Midrange Systems Technical Discussion
Subject: SQL Subselect to perform a cross-tab query
I have a file that looks like this:
PZSTAT | PZRQTP | COUNT |
--------------------------
C | 1 | 6 |
--------------------------
N | 1 | 1 |
--------------------------
C | 2 | 18 |
--------------------------
I | 2 | 1 |
--------------------------
N | 2 | 2 |
--------------------------
C | 3 | 3 |
--------------------------
C | 5 | 2 |
--------------------------
N | 5 | 3 |
--------------------------
Is there any way to use subselects in sql to transform it to the following:
pzrqtp | C | I | N
------------------------------
1 | 6 | | 1
------------------------------
2 | 18 | 1 | 2
------------------------------
3 | 3 | |
------------------------------
5 | 2 | | 3
------------------------------
Thanks!
Mike E.
_______________________________________________
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list
To post a message email: MIDRANGE-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/midrange-l.
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2025 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.