Skip to content

SELECT *, SUM(NET) AS TOTAL FROM TABLE1 WHERE CLAUSE

I was hoping to add an IF statement before WHILE. Which will still display records even there is no match dv_id on both table2. It should still display records.. The COLUMN ROLLS IF No match it will display a 0.00 value. LINK>> http://i599.photobucket.com/albums/tt79/emcevo/viewphpdisplay_zpsfc6a8174.jp…

SQL non alphabetical order in WHERE IN

Let’s say I have this query: the result is: which is ordered by the alphabetical order How can I get a result order by the index of appearance in the list? basically I want this as a result: Answer This is quite a popular approach to sort things in SQL, so I’ve blogged about this example here. You…

Postgresql query between date ranges

I am trying to query my postgresql db to return results where a date is in certain month and year. In other words I would like all the values for a month-year. The only way i’ve been able to do it so far is like this: Problem with this is that I have to calculate the first date and last