bob90937
bob90937

Reputation: 563

save view error for google big query SQL

i have the sql query on the google bigquery

SELECT distinct

 h.transaction.transactionId,
  Date,
  totals.pageviews,

  h.item.itemQuantity,
  h.transaction.transactionRevenue,
  totals.bounces,
  fullvisitorid,
  totals.timeOnSite,
  device.browser,
  device.deviceCategory,
  trafficSource.source,
  channelGrouping,
  h.page.pagePath,
  h.eventInfo.eventCategory,
  device.operatingSystem



FROM `atomic-life-148403.148778266.ga_sessions_*`,
UNNEST(hits) AS h


WHERE
  _TABLE_SUFFIX BETWEEN REPLACE(CAST(DATE_ADD(CURRENT_DATE(), INTERVAL -1 YEAR) AS STRING), '-','')
  AND CONCAT('intraday_', REPLACE(CAST(DATE_ADD(CURRENT_DATE(), INTERVAL 0 DAY) AS STRING), '-',''))
order by date

The Error IS:

Error: Encountered " "YEAR "" at line 32, column 75. Was expecting: ")" ...

However, I do not see what is wrong with "year". Can anyone help with it?

Upvotes: 0

Views: 164

Answers (1)

Daryl Wenman-Bateson
Daryl Wenman-Bateson

Reputation: 3939

you are using BigQuery Standard SQL, but running under Legacy SQL.

Go to

  • Show Options
  • Deselect SQL Dialog = Use Legacy SQL

enter image description here

Upvotes: 1

Related Questions