A SQL Tip

by jon on March 9, 2010
in Tech

After all my other posts, I thought I’d do a technical one this time. Having used SQL for the past 14 years, you tend to pick up some useful tips here and there. I’d like to share one that I read in an online article some years back (would’ve linked back to the article but couldn’t remember where I read it).

Any programmer who has worked with databases would (hopefully) know at least basic SQL. And, as with other programmers, they would typically construct their SQL queries “from the top down”, meaning they would start with SELECT and end with ORDER BY. Although this method follows your flow of reading, it doesn’t really follow the flow of logic. Think for a second–how many times have you started writing a query but had to stop in the middle to regroup your thoughts? This other method that I read about aims to minimize those instances.

The key to this alternate method is the sequence of how you write the query. In a nutshell, you write the query clauses in the following order:

  1. FROM
  2. WHERE
  3. SELECT
  4. GROUP BY (if applicable)
  5. HAVING (if applicable)
  6. ORDER BY

At first glance, it seems a bit disorganized, doesn’t it? But there’s good reason behind the ordering–it makes completing the query easier and helps you spot potential errors too.

1. FROM

Why start with FROM? Because before you even think about what columns to select, you first need to know where they are coming from. This gives you a good idea of the scope of your result set which will help you later with joins and aggregates. Plus, many SQL tools will typically “auto-complete” column names as you type them, but it can only do that after you have identified the tables.

2. WHERE

Next is WHERE, because you want to immediately (1) join your tables, and (2) filter your data set. (Note that I am not using the JOIN clause here, but you can; I’m just old school). An important rule here: if you have X number of tables, then you should have at least (X – 1) join lines so you don’t end up with a cartesian product. For example, for 4 tables you’ll need at least 3 joins. It doesn’t matter how the tables are related to each other; you will always end up with a cartesian product if you don’t follow this rule. After finishing the joins, add the other WHERE clauses to filter your data set. Having started with earlier versions of Oracle (7.x) that still required optimizing, we were taught to construct WHERE clauses in a particular order: join all tables first, then add each filter based on the number of records it filters out, from the most to the least. Nowadays though Oracle’s optimizer has gotten to the point where it’s not necessary to do this anymore, but it’s still good discipline to do so.

3. SELECT

Only now do you put in the columns to select. By doing it at this point, you minimize any errors with ambiguity because you have already laid out your tables. Also, as mentioned above, your SQL tool will probably auto-complete your column names, saving you time. If you’re doing any grouping, you’ll also include your aggregates here.

4. GROUP BY

Because you have already laid out your SELECT columns, you won’t need to think of what columns you need to group; you can just copy your SELECT columns, excluding any aggregates.

5. HAVING

This is where you filter your data set based on any aggregates, which is easy because you’ve already listed your aggregated columns.

6. ORDER BY

Finally you order your data set. This has typically been the last step anyway, but the key here is that you get a better idea of how to sort your result set after you have defined it.

Of course there are always exceptions, but for the most part this method has made it easier for me to conceptualize and construct SQL queries. I hope this makes it easier for you too :)

Bill Gates on energy: Innovating to zero!– Part II

Lets continue our discussion based on Bill Gate’s lecture regarding alternative ways which can be used for reducing CO2 emissions.

The area required for non conventional energy sources like solar energy and wind energy is much more as compared to the conventional energy plants and the cost of construction is much high. The problem of storage of energy also exists when we try to generate energy using non conventional energy sources like wind and solar power plants.

Terra-power is one of the alternative ways for generation of energy which considers burning Uranium to 99 percent capacity which results in reduction in waste and increase in the efficiency of the nuclear power plants.

These alternative sources of energy can help us reduce the CO2 emissions by 80 percent by 2050. Implementation of all these alternatives would need substantial investment in research projects, provision of subsidies to those who try to implement these ideas.

The key part in this process is to come up with a solid research which will lead to pilot research projects. These pilot research projects can then lay the foundation for multiple possible solutions which can be implemented on mass basis.

It is quite important than different people come up with different research ideas which will give us more possibilities of success in reducing the emissions. There is also a chance that different approaches can be combined to create more cheap and sustainable solution.

Gasoline

by gcastell on March 5, 2010
in Uncategorized

I am in a journey to try to find if 2 theories of my friends are correct, I think they are wrong but who knows, I may be wrong!

Theory 1: Mobile Gas is better than BJs Gas and gives better mileage. 

Theory 2: Premium gas gives better mileage.

And how I am planning to find if these theories are correct or not? Easy, I have my 2 cars using BJs regular gas for 3 months, here are the results:

Honda Odyssey 2007
Cost per 100 miles: 17.57

Ford Focus 2001
Cost per 100 miles: 12.75

This month I switched the focus to mobile  and the odyssey to premium. From my perspective, my friends will be right if the cost per 100 is the same or less.

We should know in 3 months, stay tuned!

JJIS Celebration Party

by kilaruss on March 4, 2010
in Uncategorized

On last Friday 26th, 2010 we had celebrated JJIS migration to .Net Framework 3.5. All the team worked very hard to meed dead lines as took longer than planned and finally completed. We see the better performance and fresh descent look. We celebrated this occasion with great food like Italian, Mexican, Indian and American dishes like Pizza, Tacos, Chicken Biryani, Tandoori Chicken, Quesadillas and desserts like Cake and Flan De. All of we had lots of food  and enjoyed.  Still I remember taste of the Cake, it was awesome and I felt it was the best cake I ever had and every one felt it was awesome. I had lots of cake after several months as I couldn’t resist even though I limited eating bakery items. Other best cakes I had when  Chandini made them. When Chandini prepared I used to like it, but the topping was normal taste. Other best cakes I had were from Hot breads(NJ and Boston), Villa Italia(Schennectady), Vanilla Bean( Latham).  Alao I liked Flan De and Tandoori Chicken. Other food was ok.  Normally my favorites are Appetizers and Desserts than Main entries in any party except when we go to restaurant. Most of the times I taste dessert even before Appetizer if I have a chance.  Now you might have understood how I love desserts and appetizers. I don’t want to continue any more  as I finished my 2oo words, Thanks for your patience.

My New Car Part II

by Phani on March 4, 2010
in Uncategorized

Guys,

Today i would like to talk about the second day of my car experience.The next day after i bought the car.I woke up around 6.30 Am in the morning and looked at my car from the window of my room and saw my car being getting wet in the rain.I got ready quickly and then i placed the Napkins in the car and gave message to the guys that i am bringing my car to the office as we are doing the car pool and started my car and drove to Kanaka’s home and by the time sridhar and aravinda are waiting out side for me.

As soon as i came there Kanaka also came out from his home and everyone congratulated me after looking at my New car and they got into the car and we started to office,as i am in hurry of driving my new car i didnt notice that one of the car door was not proper shut and after i was on the interstate on I-787 and noticed that the car door is not shut and we guys made a small stunt in opening the car door and closing on while on drive and finally pulled over and find the door on Aravinda’s side is not shut properly

After closing the door properly we started back to office and reach office on time and luckily everyone got a good point as we made it on time:P

Bill Gates on energy: Innovating to zero!– Part I

by dhairyashil1 on February 28, 2010
in Uncategorized

Following are the notes taken from the lecture delivered by Bill Gates regarding the energy issues:-

Price of energy has declined over the decades. As the energy consumption increases, the CO2 emissions increase in proportion. This leads to increase in the average temperature. The only solution to this problem is reduction in energy consumption which can lead to reduction in CO2 emissions. The world today has a population of around 6.8 billion. The amount of CO2 emissions are directly proportional to population, services consumed by people, efficiency of the services and amount of CO2 generated per the unit of energy production.

This demands for finding out the ways in which we can control the population. It also demands for devising the efficient services which consume less energy for the same amount of work done. The major solutions which we can consider for energy production are :-
1)Carbon capture while producing the energy using fossil fuels: This demands for designing the system to trap the carbon produced by burning the fossil fuels , pressurize it to convert it into liquid form and store it. The storage can be a critical issue as the volume would be high.
2)Nuclear Energy: – The problems to be solved with this would be the cost of energy production, safety and the long term waste.
3)Wind Energy
4)Solar Energy
5)Solar Thermal Energy

We will continue this discussion in the next part.

MY New Car

by Phani on February 25, 2010
in Uncategorized

Guys,

I would like to tell you about my First New Car that i own now.It is Honda Civic Ex-L 4dr sedan automatic transmission with fully loaded except the Navigation system.I became the owner of this car on Feb 24th 2010 at 4.00PM as i received the keys of the vehicle at the dealer.

On Feb 24th i was having the appointment with th dealer to pick my car at 3.00PM and i thought that i couldn’t pick up the car on that day as from the day previous we were having the snow storm which was lasting the whole day i.e on 24th as per the weather reports.

But due to god’s grace the snow storm stopped at 2.00 PM and i started to meet the dealer from the office around 2.30 and taken the bus and reached my home and i was waiting from my friend who has to pick me up and drop at the dealers place.and my friend arrived at 3.00PM and we started at around 3.10PM and reached there by 3.30 PM and then the sales person came and meet me and then some paper work stuff has been done and he handed over the car keys to me at around 4.00PM and then i started from there and came to my home and then taken some lovely pics of my car to show them to my sister and my parents.After i took the pictures me and my roommate started to temple to get the car pooja done.First went to the indian store on the central ave and taken the stuff that are needed for the pooja and reached the temple around 6.00 PM and then the priest was there and he performed the pooja and after that i payed the amount to the temple towards the pooja and offered some tip to the priest for performing the pooja and after that went inside the temple and prayed to god and came back to home around 7.30 PM.

I am so happy that i became the owner of a New car.

I LOVE MY CAR VERY VERY VERY MUCH. :-)

Experience In Buying My New Car

by Phani on February 18, 2010
in Uncategorized

Guys,

I would like to share my experience with the dealers in buying my new.Though i haven’t bought the car yet i would like to share the experience that i have faced with the dealers in Albany NY.Actually i was planning to buy the Honda Civic Ex-L 4Dr Sedan car in the month of April on my birthday but as i have seen that they were some deals going on for the Presidents Sale.After doing some research on the internet for the prices paid for the car i was planning to buy.One fine day which is on Valentines day i went to the local dealer in Albany.As soon as i entered the show room the sales person greeted me with a nice smile and the conversation went on like this.

Salesman: Good Morning
Me: Very Good morning

Salesman: How can i help you on this fine day gentleman
Me: I am planning to take a new Honda Civic

Salesman: Do you have any model and wanna have the test drive of the vehicle.
Me: Honda Civic Ex-L and i told him that i would like to take a Test Drive.

Salesman: Sure ,why not and he went inside to look if he has got any of the Ex-L cars n the stock and came with the key and asked me my License and i gave him my license and he took me to the car and showed all the options available in the car and asked me to go for the drive and come back and park the car in the parking lot.
Me: I was so excited and listened to his words and then adjusted my mirrors and started the car and i was feeling that i have been in the car which i will the owner of that car and started for the drive.

In the Next post i would like to say you how i felt in driving the new car and how my experience with the dealer went on.Until then keep hanging on -:)

Tumbling Tykes

by jon on February 16, 2010
in Family

Last Monday, we thought of visiting this place for toddlers in Latham called Tumbling Tykes. My wife had seen it in one of the blogs she reads and she said it had gotten good reviews. One of our friends also attended a birthday party that was held there and she said that we should check it out because our son might like it.

So Monday being a holiday, it was perfect timing for us because they were open the whole day, whereas during the weekend they are only open in the morning. The fee is seven dollars, which is good for the whole day. The place has adequate space, probably 30 by 100 feet give or take, and has lots of toys and activities. One corner is dedicated to children below two years old, so they have toys there like the push toys and musical instruments. The rest of the room is for the older kids, with toys of different kinds. There are at least three slides of different heights and slopes. There is balance beam about a foot from the floor. There are two trampolines, one small and one big. There is a small monkey bar and a big monkey bar. There are two mini-cars that go up and down a mini-roller coaster. There are at least four little tykes cozy coupes. There is an incline (made with soft padding) where kids can roll down. And there are also many different kinds of little toys and costumes.

They also offer different kinds of classes for different age groups. We thought the atmosphere was good and the quality of the toys and environment was good, plus it’s nearer than Treepaad!

Sendhil Mullainathan: Solving social problems with a nudge

by dhairyashil1 on February 15, 2010
in Uncategorized

Following are the notes taken from the lecture given by Sendhil Mullainathan:-

Diarrhea can be attributed as one of the major reasons for child mortality in India.  In 1960, India had child mortality rate closer to 24%. Diarrhea was one of the major reasons for the mortality. The efforts were taken to reduce the deaths due to diarrhea. One of the major solutions was the use of oral rehydration salts.

Current child mortality rate in India is closer to 6.5%. Nearly 400,000 children die annually in India even today. Many of these deaths are preventable.The problem with eliminating the problems like diarrhea completely lies in educating people about the solutions. Most of the people do not believe in the solutions ,as the solutions don’t seem to be logical to them. If we ask the people in remote villages in India: ” Should we increase or decrease the water consumption for the kids having diarrhea?”

At lease 50 percent of the people would answer that the water consumption should be reduced.The problem lies in the education of the people about solution to the problem. Most of the times scientific
advance do not gurantee a solution as long as the awareness regarding the solution is not generated among the people. Complete elimination of the diarrhea needs generation of awareness regarding the use
of rehydrations salts as a prominent solution for diarrhea.

Next Page »