Hi,
I am new to Looker but very experienced in SQL. I attended the LookerML seminar yesterday and the instructor told me that a self-join within a dimension is possible. Looker documentation supports that SQL queries can be incorporated into a dimension LookerML statement. However I am getting conflicted information on how to construct this or if it is even possible.
Here is what I am trying to do: Create a dimension where I self join a table to return the records that only contain the most recent invoice date for a given account ID. Comparing account IDs and the max invoice date to existing invoice date. Returning the Invoice Number meeting this criteria. This statement can be made in the SQL runner but I am not really sure how to incorporate this into a look. Which is where it would be actually used.
Can anyone assist me in resolving this?
dimension: most_recent_invoice_number {
type: string
sql: (
SELECT ${invoice_number}
FROM invoice_table as it
INNER JOIN it
ON it.account_id = ${TABLE}.account_id AND it.max_invoice_date =
${TABLE}.invoice_date ) ;;
}