Tuesday, March 27, 2012

Create Table Question

Hi

Im wondering if someone could help me out with how to write sql for the following type of query.

I have 3 known strings of characters and three associated sql queries. The queries will always return an integer.

I want a table so that column 1 is the list of known strings, and column 2 is the results of the three queries.

Thank youcreate table mytable
( string varchar(100)
, result integer
)|||Or maybe something like this:
create table mytable
( string varchar(100)
, result integer)
AS
select string, SUM(result) from (
select string, result from query1
UNION ALL
select string, result from query2
UNION ALL
select string, result from query3)
group by string;
:D

No comments:

Post a Comment