SQL query to export ChannelReference or Reference (in place of ExternalReference)

I have an SQL query which exports the ExternalReference field fro Linnworks, here's the command I use in an SQL script (run from Query Data)...

ExternalReference AS 'ExtRef',

...however I've noticed that in the past few days, this ExternalReference data is missing from LW orders (i.e. ordrs that Linnworks has retrieved from Amazon)...however, fortunately it seems that for Amazon the missing data can also be gleaned from ChannelReference (or Reference) i.e. the same data that I need that's missing, therefore how can I export the ChannelReference (or Reference) from LW.

neither of these commands work in my SQL script...

ChannelReference AS 'ExtRef',

Reference AS 'ExtRef',

Many thanks!

Ok, I sussed it (by using template designer I was able to glean the varable I needed), this gets me going...

'ExtRef' = CASE
               WHEN o.source = 'Amazon FBA' THEN ReferenceNum
               WHEN o.source = 'Amazon' THEN ReferenceNum
               else ExternalReference


Login to post a comment