October 26, 2024
Chicago 12, Melborne City, USA
SQL

Odd error in a BigQuery SQL Query, looking for an explanation


SELECT 
    DISTINCT 
    CONCAT(ue.vb_name, ue.b_name) AS Uber_Eats_Slug,
    CONCAT(gh.vb_name, gh.b_name) AS Grub_Hub_Slug,
    FORMAT_TIMESTAMP('%Y-%m-%d %H:%M', CAST(ue.timestamp AS TIMESTAMP)) AS uber_formatted_datetime,
    FORMAT_TIMESTAMP('%Y-%m-%d %H:%M', CAST(gh.timestamp AS TIMESTAMP)) AS grubhub_formatted_datetime
FROM 
    `arboreal-vision-339901.take_home_v2.virtual_kitchen_ubereats_hours` AS ue,
    `arboreal-vision-339901.take_home_v2.virtual_kitchen_grubhub_hours` AS gh

GROUP BY 
    Uber_Eats_Slug, Grub_Hub_Slug, uber_formatted_datetime,grubhub_formatted_datetime
LIMIT 1000;

When this query runs, it only produces one repetitive value for Uber_Hub_Slug and uber_formatted_datetime. How is this possible even when the DISTINCT Function is used, when there is no variable that differs in the data pulled. How to avoid this error and pull the required values? The data reads as it should when run separately for both datasets.



You need to sign in to view this answers

Leave feedback about this

  • Quality
  • Price
  • Service

PROS

+
Add Field

CONS

+
Add Field
Choose Image
Choose Video