How do I group by column from table A to another column in table B? SQL -
i relatively new sql server. want know if possible utilize grouping of 1 column table grouping column in table b... have tried block of code... appreciate responses. thanks!
select sum(total_likes) msn grouping select * month_ postingtable;
the problem query aren't saying how bring together msn postingtable. if msn table looks this:
msnid int, total_likes int, name varchar(50), url varchar(255) ...etc.
...and posting table looks this:
msnid int, month_ int, year_ int, posting_information varchar(255) ...etc.
then pseudo-query saying, "add total likes msn , list number against each month in postingtable". if there total of 100,000 likes in msn reply looked this:
jan - 100,000 feb - 100,000 mar - 100,000 apr - 100,000 etc.so need define how want associate total_likes each month "bucket". query might end looking this:
select pt.[month_], sum([total_likes]) msn m inner bring together postingtable pt on pt.someid = m.someid --where someid how bring together msn postingtable grouping pt.[month_]
now results should more this:
jan - 30,000 feb - 40,000 mar - 20,000 apr - 10,000 etc. sql table group-by
No comments:
Post a Comment