August 26, 2020

Is there a free database solution?

 Yes. Oracle Database XE is free for fall and supports a database of 12GB. Its is easy to install and hassle free experience.

Oracle Database XE can be download from: https://www.oracle.com/in/database/technologies/appdev/xe.html

During setup you are required to enter few admin passwords. Ensure you remember them. These are required to interact with the database at a later point of time. 

Now once you have installed the Oracle XE database how to query data or load data?

For this you need a front end application. In this case you can use Oracle SQL developer which can be download from this link depending the you machine's architecture: https://www.oracle.com/tools/downloads/sqldev-downloads.html

Once you have installed SQL developer. Add a connection using the top left green plus button. Below screen will appear. Name the connection as you require. in the ROLE adjacent to username box choose SYSDBA.


Enter Username as "SYS" and the password you have configured during setup of XE. Hostname, port and SID should be entered as per below and you should be connected to your XE database

August 25, 2020

ROLLUP function: How to get sub total row in a Oracle SQL query as output

 In oracle SQL query when you query for any data, the output is table of columns and rows selected. But there is not total added at the bottom.

How to add a total at the bottom and also how to add a sub-total for each change of value in a specific column.

select fruits, city, sum(price) from fruits_table group by rollup (fruits,city)

In the above example the table a total will be added to FRUITS level and also a sub-total will be added at each change in CITY.

However, there is catch. If there is more than one dimension (in the above example FRUITS & CITY) then you should sort the table by CITY and Fruits so that the sub-totals appear in order. Below the updated version of the example query with ordering.

select fruits, city, sum(price) from fruits_table group by rollup (fruits,city) order by city,fruits

Thanks for visiting. If you have any questions reach out to me directly at askme.kkhelps@gmail.com