How do I Put Several Select Statements into Different Columns
Posted
by Russ Bradberry
on Stack Overflow
See other posts from Stack Overflow
or by Russ Bradberry
Published on 2010-03-15T22:05:27Z
Indexed on
2010/03/15
22:09 UTC
Read the original article
Hit count: 275
I basically have 7 select statement that I need to have the results output into separate columns. Normally I would use a crosstab for this but I need a fast efficient way to go about this as there are over 7 billion rows in the table. I am using the vertica database system. Below is an example of my statements:
SELECT COUNT(user_id) AS '1' FROM event_log_facts WHERE date_dim_id=20100101
SELECT COUNT(user_id) AS '2' FROM event_log_facts WHERE date_dim_id=20100102
SELECT COUNT(user_id) AS '3' FROM event_log_facts WHERE date_dim_id=20100103
SELECT COUNT(user_id) AS '4' FROM event_log_facts WHERE date_dim_id=20100104
SELECT COUNT(user_id) AS '5' FROM event_log_facts WHERE date_dim_id=20100105
SELECT COUNT(user_id) AS '6' FROM event_log_facts WHERE date_dim_id=20100106
SELECT COUNT(user_id) AS '7' FROM event_log_facts WHERE date_dim_id=20100107
© Stack Overflow or respective owner