Skip to content

Add rows accumulated by current month

Is there a way to translate my hard coded SQL script into a dynamic? My problem with this code is that, it still adding the SEPT-DEC it should be zero since we are not yet covered this month My table Expected Result: Starts from JAN then Added the succeeding covered months. Answer You can UNPIVOT your data, u…

sql selecting unique rows based on a specific column

I have an table like this : I am trying to filter out something like this based on Col1 I am trying to get the all unique rows based on the values in Col1. If I have duplicates in Col1, the first row should be taken. I tried SELECT Col1 FROM tblname GROUP BY Col1 and got unique Col1 but

SQL table.column not working when I use it with full join

I have this SQL query: And it returns the error : “unknown column main.cname in filed list”. while the column certainly exists: seems alright. I tried using aliases but it just made it worse. I’m clueless Answer As coyeb60297 has pointed out, MySQL doesn’t do full outer joins so your q…