This repository has been archived by the owner on Nov 19, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
record_table_queries.sql
49 lines (48 loc) · 1.86 KB
/
record_table_queries.sql
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
-- Select the record data with the barcode for cycling
SELECT convert(replace(r.voltage, ',', '.'), DOUBLE) AS voltage,
convert(replace(r.current, ',', '.'), DOUBLE) AS current,
CASE
WHEN convert(replace(ids.active_material, ',', '.'), DOUBLE) > 0 THEN convert(replace(r.capacity, ',', '.'), DOUBLE)/convert(replace(ids.active_material, ',', '.'), DOUBLE)
ELSE convert(replace(r.capacity, ',', '.'), DOUBLE)
END AS specific_capacity,
CONVERT(r.cycle_id, UNSIGNED) AS cycle_id
FROM (
SELECT current,
capacity,
voltage,
barcode,
test_id,
cycle_id,
step_id,
step_type,
record_time
FROM `testlab-db`.`record`) r
JOIN (
SELECT barcode, test_id, active_material FROM `dev-db`.`ids`
WHERE barcode_corrected = '1003-BQV000000000000124-1' AND builder LIKE '%CY%'
) ids
ON ids.barcode = r.barcode AND ids.test_id = r.test_id;
-- Select the record data with the barcode for formation
SELECT convert(replace(r.voltage, ',', '.'), DOUBLE) AS voltage,
convert(replace(r.current, ',', '.'), DOUBLE) AS current,
CASE
WHEN convert(replace(ids.active_material, ',', '.'), DOUBLE) > 0 THEN convert(replace(r.capacity, ',', '.'), DOUBLE)/convert(replace(ids.active_material, ',', '.'), DOUBLE)
ELSE convert(replace(r.capacity, ',', '.'), DOUBLE)
END AS specific_capacity,
CONVERT(r.cycle_id, UNSIGNED) AS cycle_id
FROM (
SELECT current,
capacity,
voltage,
barcode,
test_id,
cycle_id,
step_id,
step_type,
record_time
FROM `testlab-db`.`record`) r
JOIN (
SELECT barcode, test_id, active_material FROM `dev-db`.`ids`
WHERE barcode_corrected = '1003-BQV000000000000124-1' AND builder LIKE '%FM%'
) ids
ON ids.barcode = r.barcode AND ids.test_id = r.test_id;