我必须更改原始内容并将其拆分,但是我不知道该怎么做。
SELECT A.QADAte, A.ProcessorType, A.ASDType ,A.Threshold, A.Accuracy, A.Accept, A.ItemsQty, C.Accuracy Accuracy01, C.Accept Accept01, C.ItemsQty ItemsQty01, D.Accuracy Accuracy07,
D.Accept Accept07, D.ItemsQty ItemsQty07, E.Accuracy Accuracy30, E.Accept Accept30, E.ItemsQty ItemsQty30
from `moonoia-bpo-run.asd.accuracies` A inner join
(SELECT ProcessorType, max(QADate) maxQADate FROM `moonoia-bpo-run.asd.accuracies` group by ProcessorType)
B ON A.QADate = B.maxQADate and A.ProcessorType = B.ProcessorType and A.SkipNulls = true and A.ASDType = '%' and A.Days=6
left join `moonoia-bpo-run.asd.accuracies` C ON C.QADate=DATE_ADD(A.QADate, INTERVAL -1 DAY) and C.ProcessorType = A.ProcessorType and C.ASDType = '%' and C.SkipNulls = true and C.Days=6
left join `moonoia-bpo-run.asd.accuracies` D ON D.QADate=DATE_ADD(A.QADate, INTERVAL -7 DAY) and D.ProcessorType = A.ProcessorType and D.ASDType = '%' and D.SkipNulls = true and D.Days=6
left join `moonoia-bpo-run.asd.accuracies` E ON E.QADate=DATE_ADD(A.QADate, INTERVAL -30 DAY) and E.ProcessorType = A.ProcessorType and E.ASDType = '%' and E.SkipNulls = true and E.Days=6
结果就是这个
我必须提取F06原始数据,并用ASDType不是'%'的2种不同原始数据来获取他。我必须将其余数据保留在表中。
请,你能帮我吗?
答案 0 :(得分:1)
您也可以在tableau中执行此操作,但是由于您直接使用查询,因此链接多个查询并获取结果集更好。
据我所知,要获得非常规的行,您需要再创建一个查询
并为两个查询进行并集。对于第二个查询,仅使用F06
和ASDType <> '%'
作为过滤器检查第二个查询,我已经添加了它
SELECT A.QADAte, A.ProcessorType, A.ASDType ,A.Threshold, A.Accuracy, A.Accept, A.ItemsQty, C.Accuracy Accuracy01, C.Accept Accept01, C.ItemsQty ItemsQty01, D.Accuracy Accuracy07,
D.Accept Accept07, D.ItemsQty ItemsQty07, E.Accuracy Accuracy30, E.Accept Accept30, E.ItemsQty ItemsQty30
from `moonoia-bpo-run.asd.accuracies` A inner join
(SELECT ProcessorType, max(QADate) maxQADate FROM `moonoia-bpo-run.asd.accuracies` group by ProcessorType)
B ON A.QADate = B.maxQADate and A.ProcessorType = B.ProcessorType and A.SkipNulls = true and A.ASDType = '%' and A.Days=6
left join `moonoia-bpo-run.asd.accuracies` C ON C.QADate=DATE_ADD(A.QADate, INTERVAL -1 DAY) and C.ProcessorType = A.ProcessorType and C.ASDType = '%' and C.SkipNulls = true and C.Days=6
left join `moonoia-bpo-run.asd.accuracies` D ON D.QADate=DATE_ADD(A.QADate, INTERVAL -7 DAY) and D.ProcessorType = A.ProcessorType and D.ASDType = '%' and D.SkipNulls = true and D.Days=6
left join `moonoia-bpo-run.asd.accuracies` E ON E.QADate=DATE_ADD(A.QADate, INTERVAL -30 DAY) and E.ProcessorType = A.ProcessorType and E.ASDType = '%' and E.SkipNulls = true and E.Days=6
union
SELECT A.QADAte, A.ProcessorType, A.ASDType ,A.Threshold, A.Accuracy, A.Accept, A.ItemsQty, C.Accuracy Accuracy01, C.Accept Accept01, C.ItemsQty ItemsQty01, D.Accuracy Accuracy07,
D.Accept Accept07, D.ItemsQty ItemsQty07, E.Accuracy Accuracy30, E.Accept Accept30, E.ItemsQty ItemsQty30
from `moonoia-bpo-run.asd.accuracies` A inner join
(SELECT ProcessorType, max(QADate) maxQADate FROM `moonoia-bpo-run.asd.accuracies` group by ProcessorType)
B ON A.QADate = B.maxQADate and A.ProcessorType = B.ProcessorType and A.SkipNulls = true and A.ASDType = '%' and A.Days=6
left join `moonoia-bpo-run.asd.accuracies` C ON C.QADate=DATE_ADD(A.QADate, INTERVAL -1 DAY) and C.ProcessorType = A.ProcessorType and C.ASDType <> '%' and C.SkipNulls = true and C.Days=6 and B.ProcessorType = 'F06'
left join `moonoia-bpo-run.asd.accuracies` D ON D.QADate=DATE_ADD(A.QADate, INTERVAL -7 DAY) and D.ProcessorType = A.ProcessorType and D.ASDType = '%' and D.SkipNulls = true and D.Days=6
left join `moonoia-bpo-run.asd.accuracies` E ON E.QADate=DATE_ADD(A.QADate, INTERVAL -30 DAY) and E.ProcessorType = A.ProcessorType and E.ASDType = '%' and E.SkipNulls = true and E.Days=6