|
|
Archives of the TeradataForum
Message Posted: Wed, 06 Jun 2001 @ 16:47:30 GMT
Subj: | | Re: Query conundrum |
|
From: | | Fred Pluebell |
You have to explicitly do (at least) two passes of the table and combine the results. The following isn't necessarily the most efficient
choice but illustrates the idea:
SELECT A.col1, A.col2, B.col3, A.col4, A.col5, A.col6
FROM
(SELECT
column_name_1,
count(DISTINCT column_name_2),
sum(column_name_4),
sum(column_name_5),
sum(column_name_6)
FROM
table_name
GROUP BY
1 ) AS A(col1, col2, col4, col5, col6)
JOIN
(SELECT
column_name_1,
count(DISTINCT column_name_3)
FROM
table_name
GROUP BY
1 ) AS B(col1, col3)
ON A.col1 = B.col1 ;
| |