I receive various data from an outside source to create reporting. Unfortunately non of this excel table has a primary key.
I have to connect the data via 'booking ID' field which has in all 3 tables muliple entries.
I entered SELECT DISTINCT in the SQL script. When I add the required fields they still deliver more rows than anticipated.
The SQL for 2 table currently is:
I have to connect the data via 'booking ID' field which has in all 3 tables muliple entries.
I entered SELECT DISTINCT in the SQL script. When I add the required fields they still deliver more rows than anticipated.
The SQL for 2 table currently is:
SELECT DISTINCT QUBE.booking_id, QUBE.cost_centre_category_name, QUBE.start_date, QUBE.amount, QUBE.costing_regular_local, QUBE.costing_offered_local, QUBE.saved, QUBE.lost, QUBE.no_of_seg_per_costing, QUBE.company_code, QUBE.company_name, QUBE.account_code, QUBE.account_name, QUBE.cost_centre_category, QUBE.cost_centre_group_code, QUBE.cost_centre_group_name, QUBE.cost_centre_code, QUBE.cost_centre_name, QUBE.number_of_pax, QUBE.booking_name, QUBE.[passenger(s)_name], QUBE.profile_unique, QUBE.costing_unique, QUBE.item_unique, QUBE.trn_number, QUBE.trn_date, QUBE.trn_type, QUBE.booking_int_flag, QUBE.booking_travel, QUBE.first_date, QUBE.last_date, QUBE.ordered_date, QUBE.segment_travel_type, QUBE.seg_provider_code, QUBE.provider_name, QUBE.preferred_provider_flag, QUBE.chain_code, QUBE.chain_name, QUBE.supplier_code, QUBE.supplier_name, QUBE.details, QUBE.segment_class, QUBE.segment_line, QUBE.segment_status, QUBE.service_code, QUBE.service_name, QUBE.first_city, QUBE.final_city, QUBE.destination, QUBE.destination_nation, QUBE.airline_designator, QUBE.ticket_number, QUBE.costing_deal_code, QUBE.no_rooms_cars, QUBE.reference, QUBE.costing_reason_code, QUBE.costing_reason_name, QUBE.miles, QUBE.ordered_by, QUBE.ordered_method, QUBE.trn_count, QUBE.costing_travel_type, QUBE.city_pair, QUBE.employee_type, QUBE.ticket_cc_fee, QUBE.best_fare_selected, QUBE.costing_exchange_ticket, QUBE.seg_first_nation_code, QUBE.seg_final_nation_code, QUBE.CLASS_GROUPING_NAME, QUBE.segment_flag, [CAR TAR].[Car type], [CAR TAR].Incidentals, [CAR TAR].[Days away]
FROM QUBE LEFT JOIN [CAR TAR] ON QUBE.booking_id = [CAR TAR].[Booking ID]
GROUP BY QUBE.booking_id, QUBE.cost_centre_category_name, QUBE.start_date, QUBE.amount, QUBE.costing_regular_local, QUBE.costing_offered_local, QUBE.saved, QUBE.lost, QUBE.no_of_seg_per_costing, QUBE.company_code, QUBE.company_name, QUBE.account_code, QUBE.account_name, QUBE.cost_centre_category, QUBE.cost_centre_group_code, QUBE.cost_centre_group_name, QUBE.cost_centre_code, QUBE.cost_centre_name, QUBE.number_of_pax, QUBE.booking_name, QUBE.[passenger(s)_name], QUBE.profile_unique, QUBE.costing_unique, QUBE.item_unique, QUBE.trn_number, QUBE.trn_date, QUBE.trn_type, QUBE.booking_int_flag, QUBE.booking_travel, QUBE.first_date, QUBE.last_date, QUBE.ordered_date, QUBE.segment_travel_type, QUBE.seg_provider_code, QUBE.provider_name, QUBE.preferred_provider_flag, QUBE.chain_code, QUBE.chain_name, QUBE.supplier_code, QUBE.supplier_name, QUBE.details, QUBE.segment_class, QUBE.segment_line, QUBE.segment_status, QUBE.service_code, QUBE.service_name, QUBE.first_city, QUBE.final_city, QUBE.destination, QUBE.destination_nation, QUBE.airline_designator, QUBE.ticket_number, QUBE.costing_deal_code, QUBE.no_rooms_cars, QUBE.reference, QUBE.costing_reason_code, QUBE.costing_reason_name, QUBE.miles, QUBE.ordered_by, QUBE.ordered_method, QUBE.trn_count, QUBE.costing_travel_type, QUBE.city_pair, QUBE.employee_type, QUBE.ticket_cc_fee, QUBE.best_fare_selected, QUBE.costing_exchange_ticket, QUBE.seg_first_nation_code, QUBE.seg_final_nation_code, QUBE.CLASS_GROUPING_NAME, QUBE.segment_flag, [CAR TAR].[Car type], [CAR TAR].Incidentals, [CAR TAR].[Days away]
HAVING (((QUBE.cost_centre_category_name) Like "*SBU*"));
Who has any constructive suggestions, how to get the correct amount of entries in my queries?FROM QUBE LEFT JOIN [CAR TAR] ON QUBE.booking_id = [CAR TAR].[Booking ID]
GROUP BY QUBE.booking_id, QUBE.cost_centre_category_name, QUBE.start_date, QUBE.amount, QUBE.costing_regular_local, QUBE.costing_offered_local, QUBE.saved, QUBE.lost, QUBE.no_of_seg_per_costing, QUBE.company_code, QUBE.company_name, QUBE.account_code, QUBE.account_name, QUBE.cost_centre_category, QUBE.cost_centre_group_code, QUBE.cost_centre_group_name, QUBE.cost_centre_code, QUBE.cost_centre_name, QUBE.number_of_pax, QUBE.booking_name, QUBE.[passenger(s)_name], QUBE.profile_unique, QUBE.costing_unique, QUBE.item_unique, QUBE.trn_number, QUBE.trn_date, QUBE.trn_type, QUBE.booking_int_flag, QUBE.booking_travel, QUBE.first_date, QUBE.last_date, QUBE.ordered_date, QUBE.segment_travel_type, QUBE.seg_provider_code, QUBE.provider_name, QUBE.preferred_provider_flag, QUBE.chain_code, QUBE.chain_name, QUBE.supplier_code, QUBE.supplier_name, QUBE.details, QUBE.segment_class, QUBE.segment_line, QUBE.segment_status, QUBE.service_code, QUBE.service_name, QUBE.first_city, QUBE.final_city, QUBE.destination, QUBE.destination_nation, QUBE.airline_designator, QUBE.ticket_number, QUBE.costing_deal_code, QUBE.no_rooms_cars, QUBE.reference, QUBE.costing_reason_code, QUBE.costing_reason_name, QUBE.miles, QUBE.ordered_by, QUBE.ordered_method, QUBE.trn_count, QUBE.costing_travel_type, QUBE.city_pair, QUBE.employee_type, QUBE.ticket_cc_fee, QUBE.best_fare_selected, QUBE.costing_exchange_ticket, QUBE.seg_first_nation_code, QUBE.seg_final_nation_code, QUBE.CLASS_GROUPING_NAME, QUBE.segment_flag, [CAR TAR].[Car type], [CAR TAR].Incidentals, [CAR TAR].[Days away]
HAVING (((QUBE.cost_centre_category_name) Like "*SBU*"));