SQL查询分组数据

时间:2018-08-01 18:36:52

标签: sql oracle oracle-sqldeveloper

我正在尝试编写一个SQL查询,该查询从以下数据中为我提供了带有“仅”管理标志“ N”的客户端列表:-

下面是一个带有两列client和admin标志的表

Client  Admin_Flag
1          Y
1          N
2          Y
3          Y
3          N
2          Y
4          Y
4          N
6          N

我上面的输出应该只有6

4 个答案:

答案 0 :(得分:1)

为此,我喜欢model = Sequential() model.add(LSTM(1, input_shape=(23,16),return_sequences=True)) # model.add(Flatten()) model.add(Dense(1, activation='tanh')) model.compile(loss='mae', optimizer='adam', metrics=['accuracy']) model.summary() X = np.random.random((56,1, 23, 16)) y = np.random.random((56,1, 23, 1)) X=np.squeeze(X,axis =1) #as input shape should be (`batch_size`, `timesteps`, `features`) y = np.squeeze(y,axis =1) model.fit(X,y,epochs=1, verbose=1, shuffle=False, batch_size = len(X)) File data = new File(SOLD_HOUSES_DATA); Scanner houseData = new Scanner(data); int totalHouses = 0; // Count the lines while (houseData.hasNextLine()){ totalHouses++; // Forgot this line houseData.nextLine(); } // Allocate array double[] o = new double[totalHouses]; // Close and re-open the scanner to reset it houseData.close(); houseData = new Scanner(data); // Read through the file a 2nd time int lineNumber = 0; while (houseData.hasNextLine()) { // Parse the data into the array (needs error checking...) String lineData = houseData.nextLine().split(","); o[lineNumber] = Double.parseDouble(lineData[2]); lineNumber += 1; }

group by

答案 1 :(得分:1)

select client
from your_table
group by client
having sum(case when admin_flag <> 'N' then 1 else 0 end) = 0

答案 2 :(得分:0)

使用first_value函数:

select distinct first_value(client) over (order by client desc) as last_client
  from tab
 where Admin_Flag = 'N';

Rextester Demo

答案 3 :(得分:0)

DateTime DOB = DateTime.ParseExact(DOBText.Text.ToString(), "dd/MM/yyyy", CultureInfo.InvariantCulture); 是必经之路。

Group by