Good Team Plays Hard
In: Photography
2 Mar 2010In this article we will go over basic understanding of Rollup clause in Oracle and SQL Server. ROLLUP clause is used to do aggregate operation on multiple levels in hierarchy. Let us understand how it works by using an example.
Consider a table with the following structure and data:
MSSQL
CREATE TABLE tblPopulation (
Country VARCHAR(100),
[State] VARCHAR(100),
City VARCHAR(100),
Population INT
)
GO
Oracle
CREATE TABLE tblPopulation (
Country VARCHAR(100),
State VARCHAR(100),
City VARCHAR(100),
Population INT
)
INSERT INTO tblPopulation VALUES('India', 'Delhi','East Delhi',9 )
INSERT INTO tblPopulation VALUES('India', 'Delhi','South Delhi',8 )
INSERT INTO tblPopulation VALUES('India', 'Delhi','North Delhi',5)
INSERT INTO tblPopulation VALUES('India', 'Delhi','West Delhi',7)
INSERT INTO tblPopulation VALUES('India', 'Karnataka','Bangalore',9)
INSERT INTO tblPopulation VALUES('India', 'Karnataka','Belur',2)
INSERT INTO tblPopulation VALUES('India', 'Karnataka','Manipal',1)
INSERT INTO tblPopulation VALUES('India', 'Maharastra','Mumbai',30)
INSERT INTO tblPopulation VALUES('India', 'Maharastra','Pune',20)
INSERT INTO tblPopulation VALUES('India', 'Maharastra','Nagpur',11 )
INSERT INTO tblPopulation VALUES('India', 'Maharastra','Nashik',6)
Now, we need to create a report on population at 3 levels: City, State and Country.
Can we do it by using SUM with GROUP BY clause?
Yes, we can, but we will have to write a separate query to GROUP BY at each level and then union the result of all queries; even after this, the proper ordering or the result would still need more work.
However, SQL Server provides a very easy solution. Just add the WITH ROLLUP clause in GROUP BY and you get the desired results.
MSSQL
SELECT Country,[State],City,
SUM (Population)
FROM tblPopulation
GROUP BY Country,[State],City WITH ROLLUP
Oracle
SELECT Country,[State],City,
SUM (Population)
FROM tblPopulation
GROUP BY ROLLUP(Country,State,City);
In: Ubuntu or Linux
26 Feb 2010Step 2:
Install Webshots
Go to webshots.com and download your webshots to the desktop. Open it with wine and go through the next-next windows.
Install it in “C:\Program Files\Webshots\”
Step 3:
Make script
Go to “Applications –> Accessoires –> Text Editor” and paste the following code in it:
#!/bin/bash cd /tmp echo "$1" > wbsht sed -i -re 's/\//\\/g' wbsht argument1=`cat wbsht` argument2=`echo z:` argument3=`echo -n $argument2 echo $argument1` rm wbsht wine "C:\Program Files\Webshots\Launcher.exe" "$argument3"
And save it.
Step 4:
Download your photos.
Go to Webshots.com and download your photo. Firefox asks you if you want to open it, or save it. Choos open ands click ‘browse’ and choose the script you’ve saved in step 3.
Step 5:
Install UWC.
Download UWC here. And install it just like webshots.
Step 6:
Run UWC.
Go (in UWC) to Conversion –> Batch conversion. Select ‘+folder’ and choose ‘”My Documents –> Webshots Data”.
Select a destination folder, and click let’s convert!
Since an update webshots doesn’t work anymore. Here is an workaround (run this in a terminal):
cd ~/.wine/drive_c/windows/system wget http://www.dll-files.com/dllindex/download.php?mfc42download0VMfWEdMdO -O mfc42.zip unzip mfc42.zip rm mfc42.zip cd ~
In: Gadget News
25 Feb 2010In: Gadget News
25 Feb 2010In: Gadget News
25 Feb 2010In: Ubuntu or Linux
21 Feb 2010I have just installed Ubuntu Linux. But, what is the default root password? I can only login as a normal user. How do I login as root user?
This is the mystery for most users – you didn’t set a root password, so what is it? The root user (also known as superuser), is a user on Ubuntu Linux and Unix-like systems with full administrative privileges (full access). So using root account for daily work can be very dangerous and you may damage your working system.
By default root account is locked under Ubuntu Linux. Therefore, you cannot login as root or use ’su -’ command to become a superuser. To run all administrative command use sudo command. sudo allows a permitted user to execute a command as the superuser or another user. Ubuntu setup your default account (the one created during installation) to run all administrative commands.
For example create a new user called bar, you need to type sudo command as follows:
$ sudo adduser bar
Password:
When sudo asks for a password, you need to supply YOUR OWN password. In other words a root password is not needed. Here are few more examples.
$ sudo /etc/init.d/ssh stop
$ sudo /etc/init.d/networking restart
Note that this is not recommended until and unless you are an expert and aware of what you are typing:
$ sudo -i
Above command will start /bin/bash as a root shell so that you can enter a root user command without using sudo command.
Open terminal and simply type the following command:
$ sudo bash
OR
$ sudo -s
Supply your password and you will become a root user.
This is a place I create just for fun and to write down some experience and notes for myself. So feel free to enjoy and drop any comments you have. I had been employed as Programmer, System Analysts, System Administrator, DBA and Project Manager. I will share some of my case study here as well. Enjoy!