devxlogo

Tip Bank

Handling Cumulative Totals in T-SQL

Suppose you have a table: select * from tblTestName Amount— ——A 10B 20c 40D 50E 30 The following single SELECT query can be used to calculate cumulative totals: –//////////////////////////////////////SELECT t1.Name,

Use the Proper Combinations of New and Delete

The following code is bad: char* charpointer= new char[SOMECONSTANT];delete charpointer; // should have been delete [] charpointer; new and new[] are allowed to use different memory pools. The default new/delete

Conditional Sorting in T-SQL

There may be certain situations where you have to sort character-based columns in a particular order.For example, Let us consider a table: –///////////////////////////////////SID Subject Marks— —— —–1 Physics 801 Chemistry

The Storage Type of Temporaries

A temporary object is destroyed at the end of the full expression in which it was created. Consider the following example: #include #include // for strlen()string s1, s2;int len=(s1+s2).c_str(); //

How to Set an Image as Background to a Frame

After all component settings, create an ImageIcon object with your desired image. Using this object, create a JLabel. Add the Jalbel to the lowest LayeredPane of the JFrame. Finally, add

Checking for Null After New (2)

Normally, you should not check for null after creating an object. MyObject o = new MyObject(); This check is not required in Java because ‘new’ is not allowed to return