sql server 2005 - SQL grouping and sum -



sql server 2005 - SQL grouping and sum -

i know how next result set out of current result set.

my query this:

select substring(col1, 1, 3) 'series', b.col2, cast(c.price * c.qty money) total tablename inner bring together .... ... date between '1/1/2012' , '1/31/2012' , b in ('c50', 'c51', 'c52', 'c53', 'c54') grouping col1, b.col2, c.price, c.qty

and returns result set:

series col2 total ---------- ---------- ---------- 105 c50 5.00 105 c50 15.00 105 c53 20.00 105 c53 20.00 105 c53 20.00

and how work:

series col2 total ---------- ---------- ---------- 105 c50 20.00 105 c53 60.00

thank you

group computed column : substring(col1, 1, 3) .

select sub.series, sub.col2, sum(sub.total) ( select substring(col1, 1, 3) 'series', b.col2, cast(c.price * c.qty money) total tablename inner bring together .... ... date between '1/1/2012' , '1/31/2012' , b in ('c50', 'c51', 'c52', 'c53', 'c54') ) sub grouping sub.series, sub.col2

sql sql-server-2005

Comments

Popular posts from this blog

How do I check if an insert was successful with MySQLdb in Python? -

delphi - blogger via idHTTP : error 400 bad request -

postgresql - ERROR: operator is not unique: unknown + unknown -