Skip to main content

Posts

TOP n of Each -- SQL

Suppose you have a table like this and want to know say the Latest 5 [INPUT] values for all [INST] ie; you have to sort a given INST by date (descending), take the 5 top most from the result. Repeat for each INST and merge all results together. Pretty easy if you have a FOR EACH or some other type of LOOP. [DW_X] ID PROP INST INPUT UPDATEDATE USERID DOMAIN 12 4 1 KUJU 7/14/2009 11:27 1 1 13 4 1 KUJU2 7/14/2009 11:28 1 1 14 4 1 Kuju 7/14/2009 13:41 1 1 15 4 1 kuju2 7/15/2009 9:48 1 1 16 4 1 Kuju3 7/15/2009 13:47 1 1 17 4 6 litlOne 7/15/2009 15:11 1 1 21 4 7 Kuju no 7/16/2009 9:59 1 1 22 4 7 Test1 7/16/2009 13:08 1 1 23 4 7 test2 7/16/2009 13:09 1 1 24 4 1 B 5/16/2009 13:09 NULL 0 25 4 1 C 5/16/2009 13:09 1 0 26 4 1 AA 5/16/2009 13:09 1 0 27 4 1 WW 5/16/2009 13:09 1 0 28 4 1 RR 3/16/2009 13:09 1 0 Instead of loops, you can achieve this by a single SQL statement. Was trying and it works out like this (MS SQL syntax) SELECT * FROM DW_X T1 WHERE T1.ID IN (SELECT TOP 5 T2.ID FROM DW_X T2 WH...

Gayathri Mantras

I have been repeating this since age 5 in the order specified. Thanks to my parents! Upto me to teach it to Nandan OM ekadantAya vidmahe vakratuNDAya dhImahi , tanno dantiH prachodayAth .. OM tatpuruShAya vidmahe mahAdevAya dhImahi , tanno rudraH prachodayAth .. OM dAsharathAya vidmahe sItAvallabhAya dhImahi , tanno rAmaH prachodayAth .. OM devakInandanAya vidmahe vAsudevAya dhImahi , tanno kRiShNa prachodayAth .. OM kAtyAyanyai vidmahe kanyAkumAryai dhImahi , tanno durgA prachodayAth .. OM mahAdevyai cha vidmahe viShNupatnyai cha dhImahi , tanno lakShmIH prachodayAth .. OM vAgdevyai cha vidmahe kAmarAjai cha dhImahi , tanno devI prachodayAth .. OM sarvasaMmohinyai vidmahe vishvajananyai dhImahi , tanno shaktiH prachodayAth .. OM gurudevAya vidmahe parabrahmaNe dhImahi , tanno guruH prachodayAth .. OM bhAskarAya vidmahe mahadyutikarAya dhImahi , tanno AdityaH prachodayAth .. OM bhUrbhuvaH svaH tatsaviturvareNyaM bhargo devasya dhImahi , dhiyo yo naH prachodayAth .. Om Tryambakam Yajama...

Shipment Rates Object

A shipment carried by a haulier has a quoted rate that depends on the value of different variables. I have been scratching my head for considerable time over this .. I do have some ideas, maybe it will work. Would appreciate if someone can put give their inputs Shipment = S1 Source = L1 Destination = L2 Rate = $1.7532 / kg if Gross wt > 1000kg AND Rate = $1.2365 / kg if Gross wt > 3000kg AND Sender = "Phutt Air Ltd" ... Shipment = S2 Source = L1 Destination = L2 Rate = 0.00 if Sender = "Singh is Kingg Ltd" ----------------- Object structure?

Everybody loves a good Whine

I have a problem with Whines published in mass media which are predominantly based on prejudice. http://www.hindu.com/2009/03/18/stories/2009031855770800.htm It doesnt appeal to me at all when the author portrays rural India , column after column, as a joyless, hopeless place that cannot change from within. Some can be very good at listing problems. I believe though that true ingenuity and courage, lies in proposing concrete solutions. Courage, because what one proposes might fail and he/she has to be brave enough to own up the failure. Individuals with a self perception of being weak will usually try align with the winning side. They do not take risks by having clear cut positions. Instead, the preffered low risk approach is blaming current systems and leaving the proposed alternate system with specs vague enough to be disowned. This ensures that you always fall on the correct side of history. Mr.S seems to imply that the only economy that can be 'just' is a communist-socialis...

The best pen in the world

If you still write instead of typing, then this is the pen I would recommend. The writing is near perfect & my handwriting never appears better. The engineers who spent days and nights solving viscosity problems, barely get the recognition they absolutely deserve. (Funny, when i read about certain creators of a "search" algorithm) Here is HariOm saying THANK YOU ! Arigatou gozaimasu! The pen being mentioned is a relatively cheap ball point with a refill called SA-7 It is a 0.7mm dia.tungsten carbide ball It is manufactured by Mitsubishi Pencils/ UNI The pens that contain this refill are UNI-SAS FINE (0.7mm) I have also found that UNI Lakubo has the same refill. More info here http://www.uniball.com/catalog/show/product.php?no=26

Good ringtone, Fun advert

Although how it relates to chocolate is not very evident http://www.youtube.com/watch?v=TVblWq3tDwY

HMV

The Truth, nothing but the Truth !! http://www.hindu.com/2009/03/28/stories/2009032854911000.htm Celebrating social emancipation in Tibet N. Ram History shows that resistance to anti-feudal reform was deeply entrenched in the Dalai Lama’s theocratic regime — fusing the causes of separatism and the preservation of feudal serfdom. The events of 1959 brought forward China’s project of freeing a million serfs. Today the Tibet Autonomous Region (TAR) of the People’s Republic of China celebrates its first Serfs Emancipation Day, an official annual holiday. The commemoration has come half a century after the Democratic Reform did away with feudal serfdom and slavery and the theocratic system in Tibet, emancipated a million serfs, and laid the basis for the autonomous modern development of the region as part of the Chinese socialist system. It was on March 28, 1959 that the central government announced it would dissolve Tibet’s local government and replace it with a Preparatory Committee for ...