Last post Aug 04, 2016 02:11 PM by techviju
Aug 01, 2016 03:30 PM|sbuggle|LINK
I need to get the total for rows where one column is the same. What is the best way to do this?
Aug 02, 2016 01:16 AM|oned_gk|LINK
Use group by columnname
Aug 02, 2016 06:37 AM|Chris Zhao|LINK
You could use SUM and GROUP BY.
GROUP BY (Transact-SQL)
Aug 03, 2016 10:19 AM|eralper|LINK
SQL programmers can now use
SQL aggregate functions with Partition By clause like Count(), Sum(), Avg() etc, just like window functions Row_Number(), Rank() etc.
Here is what I can suggest to you for your requirement
COUNT(*) over (Partition By Name) name_cnt
In above code, on sample table there is a column named Name
In select list, using COUNT() with Partition By clause, you can see the count of rows on that table with the same name value
I hope it helps,
Aug 03, 2016 01:55 PM|sbuggle|LINK
ok this was a table with a column that had multiple #acc with each line have different descriptions and amounts. The person who did this before took the table and used vba to clump together with same acc# and call it a generalized description.
If I wanted to get the rows with multiple #acc numbers with totals and not use group by because none of the columns need a aggregate function... can you show me example of how to do this?
Col1 , Col2-13, TotalCost
acc #, Jan-Dec Totalcost(this is already in the table)
Aug 04, 2016 02:04 PM|techviju|LINK
if your column field is integer and there is only one column and you want total then use this query
select sum(column1) from table
not need group by
Aug 04, 2016 02:11 PM|techviju|LINK
Create a scalar value function and pass account no to get total.