Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problems with Union Query

Status
Not open for further replies.

rafal444

Programmer
Aug 11, 2006
74
US
I wrote the union query of queries A and B. When I execute each seperatly it works. When I execute A Union B I get "Division by zero" error. Does not make too much sense. Any idea?
 
Here is the query:

SELECT ID, Film, Name, MovieRelDate, StatementDate, [Domestic Theatrical Distribution Expenses Calculated], [Domestic HV Distribution Expenses Calculated], [Domestic Other Distribution Expenses Calculated], [Domestic Distribution Expenses Calculated], [Domestic Distribution Fees Calculated], [International Theatrical Distribution Expenses Calculated], [International HV Distribution Expenses Calculated], [International Other Distribution Expenses Calculated], [International Distribution Expenses Calculated], [International Distribution Fees Calculated], [International Sales Fees], [Total Revenues], [Total Receipts], [Total Distribution Expenses Calculated], [Total Cost of production], [Total Net Proceeds to Studio], [Total Distribution Fees Calculated], [DomesticBO Calculated] As [DomesticBO], [Domestic Theatrical Rentals], [Domestic HV Gross Revenue], [Domestic Pay TV Revenue], [Domestic Free TV Revenue], [Domestic TV Revenue Calculated], [Domestic VOD/PPV Revenue], [Domestic Other Revenue], [Domestic Receipts], [Domestic Revenues], [InternationalBO Calculated] As [InternationalBO], [International Theatrical Rentals (Direct)], [International HV Gross Revenue], [International Pay TV Revenue], [International Free TV Revenue], [International TV Revenue Calculated], [International VOD/PPV Revenue], [International Other Revenue], [International Receipts], [International Revenues], [Total Payout to Participants]
FROM [QryReportBase_CalculatedAll Step 3]

UNION SELECT A.FilmID, A.Film, A.Name, A.MovieRelDate, A.StatementDate, A.[Domestic Theatrical Distribution Expenses Calculated], A.[Domestic HV Distribution Expenses Calculated], A.[Domestic Other Distribution Expenses Calculated], A.[Domestic Distribution Expenses Calculated], A.[Domestic Distribution Fees Calculated], A.[International Theatrical Distribution Expenses Calculated], A.[International HV Distribution Expenses Calculated], A.[International Other Distribution Expenses Calculated], A.[International Distribution Expenses Calculated], A.[International Distribution Fees Calculated], "" AS [International Sales Fees], A.[Total Revenues], A.[Total Receipts], A.[Total Distribution Expenses Calculated], A.[Total Cost of production], A.[Total Net Proceeds to Studio] AS Expr2, A.[Total Distribution Fees Calculated], [DomesticBO] , [Domestic Theatrical Rentals], [Domestic HV Gross Revenue], [Domestic Pay TV Revenue], [Domestic Free TV Revenue], [Domestic TV Revenue Calculated], [Domestic VOD/PPV Revenue], [Domestic Other Revenue], [Domestic Receipts], [Domestic Revenues], 0 As [InternationalBO], [International Theatrical Rentals (Direct)], [International HV Gross Revenue], [International Pay TV Revenue], [International Free TV Revenue], [International TV Revenue Calculated], [International VOD/PPV Revenue], [International Other Revenue], [International Receipts], [International Revenues], 0
FROM [Existing Data] AS A
WHERE (((A.FilmID) Not In (Select B.ID from [QryReportBase_CalculatedAll Step 3] AS B WHERE FilmID = B.ID AND StatementDate = B.StatementDate)));
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top