Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
5.7 kB
4
Indexable
Never
SELECT
  'WAREHOUSE' AS column_name,
  WAREHOUSE,
  COUNT(*) AS duplicates
FROM
  TL2.BI_VIEW.ACTIVE_LOCATION_UTILIZATION
GROUP BY
  WAREHOUSE
HAVING
  COUNT(*) > 1

UNION ALL

SELECT
  'COMPANY' AS column_name,
  COMPANY,
  COUNT(*) AS duplicates
FROM
  TL2.BI_VIEW.ACTIVE_LOCATION_UTILIZATION
GROUP BY
  COMPANY
HAVING
  COUNT(*) > 1

UNION ALL

SELECT
  'ZONE' AS column_name,
  ZONE,
  COUNT(*) AS duplicates
FROM
  TL2.BI_VIEW.ACTIVE_LOCATION_UTILIZATION
GROUP BY
  ZONE
HAVING
  COUNT(*) > 1

UNION ALL

SELECT
  'ASSIGNMENTZONE' AS column_name,
  ASSIGNMENTZONE,
  COUNT(*) AS duplicates
FROM
  TL2.BI_VIEW.ACTIVE_LOCATION_UTILIZATION
GROUP BY
  ASSIGNMENTZONE
HAVING
  COUNT(*) > 1

UNION ALL

SELECT
  'SIZE' AS column_name,
  SIZE,
  COUNT(*) AS duplicates
FROM
  TL2.BI_VIEW.ACTIVE_LOCATION_UTILIZATION
GROUP BY
  SIZE
HAVING
  COUNT(*) > 1

UNION ALL

SELECT
  'MAXVOLUME' AS column_name,
  MAXVOLUME,
  COUNT(*) AS duplicates
FROM
  TL2.BI_VIEW.ACTIVE_LOCATION_UTILIZATION
GROUP BY
  MAXVOLUME
HAVING
  COUNT(*) > 1

UNION ALL

SELECT
  'TOTALLOCATIONS' AS column_name,
  TOTALLOCATIONS,
  COUNT(*) AS duplicates
FROM
  TL2.BI_VIEW.ACTIVE_LOCATION_UTILIZATION
GROUP BY
  TOTALLOCATIONS
HAVING
  COUNT(*) > 1

UNION ALL

SELECT
  'LOCATIONSWITHINVENTORY' AS column_name,
  LOCATIONSWITHINVENTORY,
  COUNT(*) AS duplicates
FROM
  TL2.BI_VIEW.ACTIVE_LOCATION_UTILIZATION
GROUP BY
  LOCATIONSWITHINVENTORY
HAVING
  COUNT(*) > 1

UNION ALL

SELECT
  'EMPTYLOCATIONS' AS column_name,
  EMPTYLOCATIONS,
  COUNT(*) AS duplicates
FROM
  TL2.BI_VIEW.ACTIVE_LOCATION_UTILIZATION
GROUP BY
  EMPTYLOCATIONS
HAVING
  COUNT(*) > 1

UNION ALL

SELECT
  'PERCENTOCCUPIEDBYVOLUME' AS column_name,
  PERCENTOCCUPIEDBYVOLUME,
  COUNT(*) AS duplicates
FROM
  TL2.BI_VIEW.ACTIVE_LOCATION_UTILIZATION
GROUP BY
  PERCENTOCCUPIEDBYVOLUME
HAVING
  COUNT(*) > 1

UNION ALL

SELECT
  'PERCENTOCCUPIEDBLOCATION' AS column_name,
  PERCENTOCCUPIEDBLOCATION,
  COUNT(*) AS duplicates
FROM
  TL2.BI_VIEW.ACTIVE_LOCATION_UTILIZATION
GROUP BY
  PERCENTOCCUPIEDBLOCATION
HAVING
  COUNT(*) > 1

UNION ALL

SELECT
  'LOCATIONOCCUPIEDBYVOLUME' AS column_name,
  LOCATIONOCCUPIEDBYVOLUME,
  COUNT(*) AS duplicates
FROM
  TL2.BI_VIEW.ACTIVE_LOCATION_UTILIZATION
GROUP BY
  LOCATIONOCCUPIEDBYVOLUME
HAVING

SQL query for finding duplicates.


veerendra kumar meka
WAREHOUSE,
COMPANY,ZONE,
ASSIGNMENTZONE,
SIZE,
MAXVOLUME,
TOTALLOCATIONS,
LOCATIONSWITHINVENTORY,
EMPTYLOCATIONS,
PERCENTOCCUPIEDBYVOLUME,
PERCENTOCCUPIEDBLOCATION,
LOCATIONOCCUPIEDBYVOLUME,
VOLUMEOCCUPIED,
UNITS,
DETERMINATION_ZONE
I have these columns in my table TL2.BI_VIEW.ACTIVE_LOCATION_UTILIZATION
Write an sql query to find duplicates in each and every column

To find duplicates in each and every column of the table TL2.BI_VIEW.ACTIVE_LOCATION_UTILIZATION, you can use the following SQL query:

sql
Copy code
SELECT
  'WAREHOUSE' AS column_name,
  WAREHOUSE,
  COUNT(*) AS duplicates
FROM
  TL2.BI_VIEW.ACTIVE_LOCATION_UTILIZATION
GROUP BY
  WAREHOUSE
HAVING
  COUNT(*) > 1

UNION ALL

SELECT
  'COMPANY' AS column_name,
  COMPANY,
  COUNT(*) AS duplicates
FROM
  TL2.BI_VIEW.ACTIVE_LOCATION_UTILIZATION
GROUP BY
  COMPANY
HAVING
  COUNT(*) > 1

UNION ALL

SELECT
  'ZONE' AS column_name,
  ZONE,
  COUNT(*) AS duplicates
FROM
  TL2.BI_VIEW.ACTIVE_LOCATION_UTILIZATION
GROUP BY
  ZONE
HAVING
  COUNT(*) > 1

UNION ALL

SELECT
  'ASSIGNMENTZONE' AS column_name,
  ASSIGNMENTZONE,
  COUNT(*) AS duplicates
FROM
  TL2.BI_VIEW.ACTIVE_LOCATION_UTILIZATION
GROUP BY
  ASSIGNMENTZONE
HAVING
  COUNT(*) > 1

UNION ALL

SELECT
  'SIZE' AS column_name,
  SIZE,
  COUNT(*) AS duplicates
FROM
  TL2.BI_VIEW.ACTIVE_LOCATION_UTILIZATION
GROUP BY
  SIZE
HAVING
  COUNT(*) > 1

UNION ALL

SELECT
  'MAXVOLUME' AS column_name,
  MAXVOLUME,
  COUNT(*) AS duplicates
FROM
  TL2.BI_VIEW.ACTIVE_LOCATION_UTILIZATION
GROUP BY
  MAXVOLUME
HAVING
  COUNT(*) > 1

UNION ALL

SELECT
  'TOTALLOCATIONS' AS column_name,
  TOTALLOCATIONS,
  COUNT(*) AS duplicates
FROM
  TL2.BI_VIEW.ACTIVE_LOCATION_UTILIZATION
GROUP BY
  TOTALLOCATIONS
HAVING
  COUNT(*) > 1

UNION ALL

SELECT
  'LOCATIONSWITHINVENTORY' AS column_name,
  LOCATIONSWITHINVENTORY,
  COUNT(*) AS duplicates
FROM
  TL2.BI_VIEW.ACTIVE_LOCATION_UTILIZATION
GROUP BY
  LOCATIONSWITHINVENTORY
HAVING
  COUNT(*) > 1

UNION ALL

SELECT
  'EMPTYLOCATIONS' AS column_name,
  EMPTYLOCATIONS,
  COUNT(*) AS duplicates
FROM
  TL2.BI_VIEW.ACTIVE_LOCATION_UTILIZATION
GROUP BY
  EMPTYLOCATIONS
HAVING
  COUNT(*) > 1

UNION ALL

SELECT
  'PERCENTOCCUPIEDBYVOLUME' AS column_name,
  PERCENTOCCUPIEDBYVOLUME,
  COUNT(*) AS duplicates
FROM
  TL2.BI_VIEW.ACTIVE_LOCATION_UTILIZATION
GROUP BY
  PERCENTOCCUPIEDBYVOLUME
HAVING
  COUNT(*) > 1

UNION ALL

SELECT
  'PERCENTOCCUPIEDBLOCATION' AS column_name,
  PERCENTOCCUPIEDBLOCATION,
  COUNT(*) AS duplicates
FROM
  TL2.BI_VIEW.ACTIVE_LOCATION_UTILIZATION
GROUP BY
  PERCENTOCCUPIEDBLOCATION
HAVING
  COUNT(*) > 1

UNION ALL

SELECT
  'LOCATIONOCCUPIEDBYVOLUME' AS column_name,
  LOCATIONOCCUPIEDBYVOLUME,
  COUNT(*) AS duplicates
FROM
  TL2.BI_VIEW.ACTIVE_LOCATION_UTILIZATION
GROUP BY
  LOCATIONOCCUPIEDBYVOLUME
HAVING



veerendra kumar meka
Continue

COUNT(*) > 1

UNION ALL

SELECT
'VOLUMEOCCUPIED' AS column_name,
VOLUMEOCCUPIED,
COUNT() AS duplicates
FROM
TL2.BI_VIEW.ACTIVE_LOCATION_UTILIZATION
GROUP BY
VOLUMEOCCUPIED
HAVING
COUNT() > 1

UNION ALL

SELECT
'UNITS' AS column_name,
UNITS,
COUNT() AS duplicates
FROM
TL2.BI_VIEW.ACTIVE_LOCATION_UTILIZATION
GROUP BY
UNITS
HAVING
COUNT() > 1

UNION ALL

SELECT
'DETERMINATION_ZONE' AS column_name,
DETERMINATION_ZONE,
COUNT() AS duplicates
FROM
TL2.BI_VIEW.ACTIVE_LOCATION_UTILIZATION
GROUP BY
DETERMINATION_ZONE
HAVING
COUNT() > 1;