• ChrisM@Work (1/11/2013)


    Paul, which table contains column 'teu'? (and 'BL_ID')

    Put that table first in the FROM list and inner join the other tables.

    Comment out all of the joins to the other tables and run the query, then uncomment one by one. This should help you to identify if one or more joins have missing criteria.

    Since you are only working with between 4 and 48 rows, it might help you to include some columns from the other tables in the output list. Start with the columns you are joining on and don't forget to remove the aggregate function from the output or you will get an error.

    Thanks Chris,

    The thing is NCV_BL table has only one row of data and it includes the column - TEU with the value 4. So if a SUM of TEU is done from this table it should only show as 4 but as I am joining to some the tables as per the requirement, I get the SUM as 48 (duplicate values due to 12 rows in the MG_VSLVOY_SCHEDULE table - 4*12 = 48).

    Is there a way to handle this query so that only the actual TEU is accounted for and not the duplicates ?

    Thanks,

    Paul