Skip to content

Instantly share code, notes, and snippets.

@remcotolsma
Last active June 12, 2019 12:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save remcotolsma/fc8e4b3c9b8348f61270a6debd7b70d7 to your computer and use it in GitHub Desktop.
Save remcotolsma/fc8e4b3c9b8348f61270a6debd7b70d7 to your computer and use it in GitHub Desktop.
Lookup query Henk.
SELECT
t.*,
d.*
FROM
(
SELECT
`company_code`,
`company_name` as `CompanyName`,
`period_start_date` as `Begindatum`,
`period_end_date` as `Einddatum`,
`document_code` as `Type_aangifte`,
`status_description` as `Status`,
'1c' as `tag_btw_aangifte`,
COAlESCE( `supplies_to_countries_within_the_ec`, 0 ) as `3b_omzet`,
COALESCE( `value_added_tax_supplies_services_other_rates`, 0 ) as `bedrag`
FROM lookup74_wp.wp_lookup_declarations
WHERE `vat_return_xbrl` > ''
AND `status` = 'active'
AND `value_added_tax_supplies_services_other_rates` != 0
AND `company_code` = '1200'
AND `period_end_date` = '20190331'
) d,
(
SELECT `office`
FROM `wp_lookup_transaction_lines`
WHERE office = '1200'
GROUP BY `office`
) t
WHERE
d.`company_code` = t.`office`
;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment