Results 1 to 2 of 2
  1. #1
    Join Date
    Jul 2004

    Unanswered: Select Statement

    Hi all,

    I need to put a select statement together that would display the list of columns as well as the sum of the values in them. I wrote two seperate select statements that accomplish that but not sure how to combine them.
    Here are the selects that I wrote:

    select sum(length((table2.col1)||') '||upper(table3.col1)||' '||upper(table4.col1)||' '|| upper(table2.col2)||' '||table2.col3))
    FROM table1, table2,table3, table4
    WHERE table1.col4 = table2.col4 and table1.col5 = table2.col5

    SELECT (table2.col1)||') '||upper(table3.col1)||' '||upper(table4.col1)||' '||
    upper(table2.col2)||' '||table2.col3||chr(11)
    FROM table1, table2,table3,table4
    WHERE table1.col4 = table2.col4 and table1.col5 = table2.col5

    Any ideas?

  2. #2
    Join Date
    Aug 2003
    Where the Surf Meets the Turf @Del Mar, CA
    Provided Answers: 1
    When N tables exist in FROM clause, a minimum on N-1 clauses need to exist in WHERE clause to avoid Cartesian Product.
    For the bottom at least 2 more AND clauses are required to avoid Cartesian Product; since TABLE1 & TABLE2 exists twice each.
    You can lead some folks to knowledge, but you can not make them think.
    The average person thinks he's above average!
    For most folks, they don't know, what they don't know.
    Good judgement comes from experience. Experience comes from bad judgement.

Posting Permissions

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