UPDATE:
It seems to be something with the use of LAST function in Databricks SQL that is behind the different outputs.
final as (select
Skolekontrakt,
SchoolYear,
sale_id,
Dato,
last(contact_id) contact_id ,
last(SisteVerdi) SisteVerdi ,
last(Status) Status ,
last(SistOppdatert) SistOppdatert ,
Webbestilling01,
Medarbeider,
SalgsenhetKat,
SalgskortOpprettet,
SalgsDato,
Avbruddsdato,
ZipCode
from HovedTABELL
group by
Skolekontrakt,
SchoolYear,
sale_id,
Webbestilling01,
Medarbeider,
SalgsenhetKat,
SalgskortOpprettet,
SalgsDato,
Avbruddsdato,
Dato,
ZipCode)
select
H.*,
year(H.SalgsDato) SignYear,
weekofyear(date(H.SalgsDato)) SignWeek,
weekofyear(H.Dato)
from
final H
where
H.Status in (10,11)
and year(H.SalgsDato) = year(H.Dato) --and weekofyear(H.SalgsDato)=weekofyear(Dato)-1
--VED STATUS I SALGSPERIODER--
and int(weekofyear(date(H.SalgsDato))) < int(weekofyear(H.Dato))
So, removing the groupby statement yields the same results in notebook and Databricks SQL. Also, using fex count and groupby produces the same output. But using LAST produces different outputs. @Retired_mod are you aware of the difference of using LAST in notebook vs SQL? Anyone else?