This repository was archived by the owner on Jan 8, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuseful_q.txt
More file actions
72 lines (55 loc) · 1.84 KB
/
useful_q.txt
File metadata and controls
72 lines (55 loc) · 1.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
--ELIMINAR PRODUCTO DE TODOS LADOS
DELETE FROM item_locations
WHERE inventory_item_id IN (171, 746);
DELETE FROM warehouse_transactions
WHERE inventory_item_id IN (171, 746);
DELETE FROM ae_items
WHERE inventory_item_id IN (171, 746);
DELETE FROM pm_items
WHERE inventory_item_id IN (171, 746);
DELETE FROM inventory_transactions
WHERE inventory_item_id IN (171, 746);
DELETE FROM check_in_transactions
WHERE id IN ( SELECT ct.id from check_in_transactions ct
LEFT JOIN inventory_transactions it ON ct.id = it.actable_id
WHERE it.id is null );
DELETE FROM check_out_transactions
WHERE id IN ( SELECT ct.id from check_out_transactions ct
LEFT JOIN inventory_transactions it ON ct.id = it.actable_id
WHERE it.id is null );
DELETE FROM delivery_items
WHERE inventory_item_id IN (171, 746);
DELETE FROM delivery_request_items
WHERE inventory_item_id IN (171, 746);
DELETE FROM withdraw_request_items
WHERE inventory_item_id IN (171, 746);
DELETE FROM bulk_items WHERE id IN (
SELECT actable_id FROM inventory_items
WHERE id IN (171, 746)
AND actable_type = 'BulkItem'
);
DELETE FROM unit_items WHERE id IN (
SELECT actable_id FROM inventory_items
WHERE id IN (171, 746)
AND actable_type = 'UnitItem'
);
DELETE FROM bundle_item_parts
WHERE bundle_item_id IN (
SELECT actable_id FROM inventory_items
WHERE id IN (171, 746)
AND actable_type = 'BundleItem'
);
DELETE FROM bundle_items WHERE id IN (
SELECT actable_id FROM inventory_items
WHERE id IN (171, 746)
AND actable_type = 'BundleItem'
);
DELETE FROM inventory_items
WHERE id IN (171, 746);
--MAS EN UBICACION QUE EN INVENTARIO
SELECT i.id, SUM(il.quantity), b.quantity FROM inventory_items i
INNER JOIN item_locations il ON il.inventory_item_id = i.id
INNER JOIN bulk_items b ON b.id = i.actable_id
WHERE i.actable_type = 'BulkItem'
GROUP BY i.id, b.quantity
HAVING SUM(il.quantity) > b.quantity