仅从表中的多个字段返回异常

问题描述

我有存储零售交易的表(交易)。我希望能够找到几个领域的独特组合。我有一个表,用于存储交易类型(在线或商店)以及客户名称,星期编号和产品类型。我需要找到共享相同客户,星期和产品的在线或商店交易,但前提是没有其他交易类型的相应交易。请参阅下面的示例...

+------------------+----------+------+--------------+
| Transaction_Type | Customer | Week | Product_Type |
+------------------+----------+------+--------------+
| Online           | 123      | 1    | Clothing     |
+------------------+----------+------+--------------+
| Store            | 123      | 1    | Homeware     |
+------------------+----------+------+--------------+
| Online           | 123      | 1    | Homeware     |
+------------------+----------+------+--------------+
| Online           | 123      | 2    | Clothing     |
+------------------+----------+------+--------------+
| Store            | 123      | 2    | Clothing     |
+------------------+----------+------+--------------+
| Online           | 123      | 2    | Sporting     |
+------------------+----------+------+--------------+
| Online           | 345      | 2    | Clothing     |
+------------------+----------+------+--------------+
| Store            | 345      | 2    | Homeware     |
+------------------+----------+------+--------------+
| Online           | 345      | 2    | Homeware     |
+------------------+----------+------+--------------+
| Online           | 345      | 2    | Clothing     |
+------------------+----------+------+--------------+
| Store            | 345      | 2    | Homeware     |
+------------------+----------+------+--------------+
| Online           | 345      | 2    | Sporting     |
+------------------+----------+------+--------------+

由此,我希望看到以下返回内容...

+------------------+----------+------+--------------+
| Transaction_Type | Customer | Week | Product_Type |
+------------------+----------+------+--------------+
| Online           | 123      | 1    | Clothing     |
+------------------+----------+------+--------------+
| Online           | 123      | 2    | Clothing     |
+------------------+----------+------+--------------+
| Online           | 345      | 2    | Clothing     |
+------------------+----------+------+--------------+
| Online           | 345      | 2    | Clothing     |
+------------------+----------+------+--------------+
| Online           | 345      | 2    | Clothing     |
+------------------+----------+------+--------------+
| Store            | 345      | 2    | Homeware     |
+------------------+----------+------+--------------+
| Online           | 345      | 2    | Sporting     |
+------------------+----------+------+--------------+

其他交易被排除在外,因为在线和商店的客户,星期和产品类型值相同。

到目前为止,我的代码是这个...

select * from transactions
group by customer,week,product_type
having count(customer,product_type) <> 2

但是我想我应该使用分区,但是我不知道怎么做。

谢谢

解决方法

您可以使用Public Function Pkcs1Pad2(data As String,keySize As Integer) As BigInteger If (keySize < data.Length + 11) Then Return New BigInteger() End If Dim buffer(256) As Byte Dim i = data.Length - 1 While (i >= 0 And keySize > 0) keySize -= 1 'VB "decrement x on previous line" = c# "decrement x then return x" buffer(keySize) = Convert.ToByte(data(i)) i -= 1 'VB "decrement x on next line" = c# "use x then return decremented x" End While Dim random = New Random keySize -= 1 'VB "decrement x on previous line" = c# "decrement x then return x" buffer(keySize) = 0 While (keySize > 2) keySize -= 1 'VB "decrement x on previous line" = c# "decrement x then return x" buffer(keySize) = Convert.ToByte(random.Next(1,256)) End While keySize -= 1 'VB "decrement x on previous line" = c# "decrement x then return x" buffer(keySize) = 2 keySize -= 1 'VB "decrement x on previous line" = c# "decrement x then return x" buffer(keySize) = 0 Array.Reverse(buffer) Return New BigInteger(buffer) End Function

not exists

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...