Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/oracle/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在此查询中使用Oracle group函数count和group by子句_Oracle - Fatal编程技术网

如何在此查询中使用Oracle group函数count和group by子句

如何在此查询中使用Oracle group函数count和group by子句,oracle,Oracle,假设Employee表有以下字段 emp_id号 名瓦查尔 租用日期 等 这可能会有帮助!。根据您的需要更换一年 Create a query to display the total number of employees and, of that total, the number of employees hired in 1995, 1996, 1997, and 1998. Create appropriate column headings. 显示您的表定义(DDL)、现有数据和S

假设Employee表有以下字段

  • emp_id号
  • 名瓦查尔

  • 租用日期 等


  • 这可能会有帮助!。根据您的需要更换一年

    Create a query to display the total number of employees and, of that total, the number of
    employees hired in 1995, 1996, 1997, and 1998. Create appropriate column headings.
    

    显示您的表定义(DDL)、现有数据和SQL(如果您还有SQL)。否则我们是瞎子,帮不了你。是的,这正是我想要的。我改变了我的查询方式——选择COUNT(*)“Total”,SUM(DECODE(to_char(雇用日期,'YYYY'),'2010',1,0))“2010 COUNT”,SUM(DECODE(to_char(雇用日期,'YYYY'),'2015',1,0))“2015 COUNT和(DECODE(to_char雇用日期,'yyyyy'),'2014',1,0))“2014 COUNT来自emp;
       SELECT COUNT(*) "Total",
      SUM(DECODE(hire_date,'2010',1,0)) "2010 Count" ,
      SUM(DECODE(hire_date,'2015',1,0)) "2015 Count",
      SUM(DECODE(hire_date,'2014',1,0)) "2014 Count"
    FROM emp;