Results 1 to 3 of 3
  1. #1
    Join Date
    Aug 2004
    Posts
    19

    Unanswered: 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 you

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    create table mytable
    ( string varchar(100)
    , result integer
    )
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  3. #3
    Join Date
    Jun 2003
    Location
    West Palm Beach, FL
    Posts
    2,713

    Cool

    Or maybe something like this:
    Code:
    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;
    The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •