sql server - Grouping and sum in sql -


i trying extract following columns sql table called vouchers:

  • date,
  • voucherid,
  • valueissued,
  • valueredeemed,
  • valueexpired

that bit straight forwards , returns below data:

enter image description here

however show them

  • by day,
  • by voucherid

and sum values each individual voucherid produce view similar below:

enter image description here

can point me in correct direction in regards sql code this?

i using ssms 2014

it's pretty straight forward

select posdate, voucherid, sum(valueissued), sum(valueredeemed)   vouchers   group posdate, voucherid 

note column dateexpired isn't correct in context. should either grouped or removed entirely (as did)


Comments

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

configurationsection - activeMq-5.13.3 setup configurations for wildfly 10.0.0 -