select distinct employee_id, first_name, commission_pct, department_id from
employees;
當我使用上述查詢時,它會導致上述所有屬性的不同組合。由於employee_id(是員工的主鍵)是唯一的,因此查詢會生成表中的所有行。對特定列使用DISTINCT
我想有一個結果集,具有不同的commission_pct和department_id組合。所以如何形成查詢。當我試圖以包括中間DISTINCT
作爲
select employee_id, first_name, distinct commission_pct, department_id from
employees;
這是導致錯誤
ORA-00936-missing expression
如何形成一個查詢其結果有佣金的唯一不同的組合和department_id.The表來自HR
模式的oracle。
您能否詳細說明您的第一個查詢返回哪些行按照您的需求不應出現的行。 – rshetye
你可以在'commission和department_id'上使用group by。如果您無法弄清楚如何操作,請回複評論。 –