A taste of Oracle 10 on Ubuntu

Applications -> Oracle Database 10g Express Edition -> Run SQL Command Line

 

SQL> connect hr
Enter password:
Connected.
SQL> desc emp_details_view


SQL> column city format a10
SQL> column country_name format a25
SQL> select city,country_name from emp_details_view

 

SQL> select hire_date, salary from employees group by to_char(hire_date,'YYYY') ;
select hire_date, salary from employees group by to_char(hire_date,'YYYY')
       *
ERROR at line 1:
ORA-00979: not a GROUP BY expression


SQL> select to_char(hire_date, 'yyyy'), avg(salary) from employees group by to_char(hire_date, 'yyyy');

TO_CHAR(HIRE AVG(SALARY)
------------ -----------
1987           14200
1997          6460.71429
2000          5381.81818
1994          9828.57143
1991            6000
1995            4525
1990            9000
1989           17000
1993           17000
1999          4938.88889
1996            8600

TO_CHAR(HIRE AVG(SALARY)
------------ -----------
1998          4873.91304

12 rows selected.

 

你可能感兴趣的:(oracle)