Skip to content

Tag: sql

Decluttering a SQL query

For a practice project i wrote the following query and i was wondering if there is way to make it more efficient than writing everything 12 times like a for loop for sql. EDIT I was given the 3 tables represented on the following database schema , and im trying to create a table with the total sales of dairy

Oracle SQL Filter common registries (1:1) between two tables

I need some help to approach a proper counting between 2 tables. There are 2 tables with duplicated fields on each table. I need to filter same registries between these 2 tables but it must be counted only once per ID on both tables. I was thinking about selecting by Distinct ID but still not getting the corr…

Assign NULL to repeated values in different columns in SQL

I have a table like this: id mail_1 mail_2 mail_3 1 john john_v2 NULL 2 clarisse clarisse clarisse_company 3 NULL julie NULL 4 mark markus_91 mark 5 alfred alfred alfred And I would like to put NULLs where the mail is repeated, for example in the row 2 mail_1 and mail_2 have the same value; clarisse, and I wo…