Tuesday, August 5, 2008

SQL: GROUP BY CUBE(column1, column2,..., column n)

Had one query where we have to give count of Surgeries done in the order of Speciality (Department), OT type, OT Category, OT Sub-Category. We wrote a simple SQL Query with Group by clause. So we were getting records like: (Example)

Speciality         Type             Category            Sub-category                 count
CTVS      Closed Heart      Congenital        Interrupted Aortic Arch        456
CTVS      Closed Heart      Congenital        Ventricular Septal Defect      678
CTVS      Closed Heart      Ischemic           Interrupted Aortic Arch        123
CTVS      Closed Heart      Ischemic          Ventricular Septal Defect       465
CTVS      Open Heart        Congenital         Interrupted Aortic Arch        138
CTVS      Open Heart        Congenital        Ventricular Septal Defect       615
CTVS      Open Heart        Ischemic           Interrupted Aortic Arch        513
CTVS      Open Heart        Ischemic          Ventricular Septal Defect       908


So, how to get Counts at all the three levels: Type, Category and Sub-category?
The trick was in use of CUBE
Syntax: group by cube(column1, column2, column3,...,columnn)
and then it gave the output, the way we wanted

Speciality         Type             Category            Sub-category                 count
CTVS      Closed Heart      Congenital        Interrupted Aortic Arch        456
CTVS      Closed Heart      Congenital        Ventricular Septal Defect      678
CTVS      Closed Heart      Congenital................................................... 1134
CTVS      Closed Heart      Ischemic           Interrupted Aortic Arch        123
CTVS      Closed Heart      Ischemic          Ventricular Septal Defect       465
CTVS      Closed Heart      Ischemic...................................................... 588
CTVS      Closed Heart......................................................................... 1722
CTVS      Open Heart        Congenital         Interrupted Aortic Arch        138
CTVS      Open Heart        Congenital        Ventricular Septal Defect       615
CTVS      Open Heart        Congenital.................................................... 753
CTVS      Open Heart        Ischemic           Interrupted Aortic Arch         513
CTVS      Open Heart        Ischemic          Ventricular Septal Defect        908
CTVS      Open Heart        Ischemic....................................................... 1421
CTVS      Open Heart ........................................................................... 2174

Cool...So, now no more struggling with multiple totals :)



SQL: GROUP BY CUBE(column1, column2,..., column n)SocialTwist Tell-a-Friend
Bookmark and Share

Spammers blast Social Networking Sites

An article on how bots are being used to create fake accounts on Social Networking Sites, starting with AOL in mid 1990s, and then phishing with user's data. A fair article here

Spammers blast Social Networking SitesSocialTwist Tell-a-Friend
Bookmark and Share

Security Jargons: Bots, Zombies, Virus, Worms, Trojan Horse & Phishing

Bots: A bot is a type of malware which allows an attacker to gain complete control over the affected computer. [SOURCE]

Zombie: Computers that are infected with a bot are generally referred to as zombies. [SOURCE]

Virus: A computer virus is a small program written to alter the way a computer operates, without the permission or knowledge of the user. A virus must meet two criteria:

  • It must execute itself. It often places its own code in the path of execution of another program.
  • It must replicate itself. For example, it may replace other executable files with a copy of the virus infected file. Viruses can infect desktop computers and network servers alike.
Five recognized types: File infector viruses, Boot sector viruses, Master boot record viruses, Multipartite viruses, Macro viruses [SOURCE]


Trojan Horse:
Trojan horses are impostors—files that claim to be something desirable but, in fact, are malicious. A very important distinction between Trojan horse programs and true viruses is that they do not replicate themselves. Trojan horses contain malicious code that when triggered cause loss, or even theft, of data. For a Trojan horse to spread, you must invite these programs onto your computers; for example, by opening an email attachment or downloading and running a file from the Internet. Trojan.Vundo is a Trojan horse. [SOURCE]

Worm:
Worms are programs that replicate themselves from system to system without the use of a host file. This is in contrast to viruses, which requires the spreading of an infected host file. Although worms generally exist inside of other files, often Word or Excel documents, there is a difference between how worms and viruses use the host file. Usually the worm will release a document that already has the "worm" macro inside the document. The entire document will travel from computer to computer, so the entire document should be considered the worm W32.Mydoom.AX@mm is an example of a worm [SOURCE]

Virus Hoax:
Virus hoaxes are messages, almost always sent by email, that amount to little more than chain letters. Following are some of the common phrases that are used in these hoaxes:
  • If you receive an email titled [email virus hoax name here], do not open it!
  • Delete it immediately!
  • It contains the [hoax name] virus.
  • It will delete everything on your hard drive and [extreme and improbable danger specified here].
  • This virus was announced today by [reputable organization name here].
  • Forward this warning to everyone you know! [SOURCE]
Phishing:
Phishing is attacks using “spoofed” e-mails and fraudulent websites with the attempt to trick unsuspecting Internet users into divulging confidential personal information such as credit card numbers, account usernames and passwords, social security numbers, etc. [SOURCE]

Update-1

Vhishing:

In a vishing scam, people are sent spam mail, as in Phishing, but instead of being directed to a Web site, they are given a phone number to call. If one calls the number, it will seem like one is calling the company that sent you the e-mail. They have all of the automated messages, hold music and even long wait times. When one finally reaches a representative, they will ask one for ones' account information.




Security Jargons: Bots, Zombies, Virus, Worms, Trojan Horse & PhishingSocialTwist Tell-a-Friend
Bookmark and Share
Blog Widget by LinkWithin
 
Clicky Web Analytics