sql - Reporting using TSQL -
i required print 2 reports in following format:
header 1 header 2 datetime sn employee/manager salary bonus john/susan 60000 5000 b jenny/gary 70000 10000 total 2 130000 15000 total bonus : 15000 total records : 2 header 1 header 2 datetime sn employee/manager salary bonus successful john/susan 60000 5000 subtotal: 1 struggling b john/susan 70000 10000 subtotal: 1 total 2 130000 15000
i have required information present in single table.
before coding, wanted ask tsql experts out there if possible in tsql? if not, i'll use procedural programming language accomplish this.
edit1: don't need display @ front end. have dump .txt file. schema example be: sn employee manager salary bonus
i'm showing sample data how can proceed in t-sql way it's depends on requirement how bind columns in front end
just assumption based on requirement can grouping or rollup
declare @t table(sn varchar(5),name nvarchar(max),datee date,sal money,bonus money) insert @t select 'a','john/susan','2012-01-02',6000,5000 insert @t select 'b','jenny/gary','2012-01-02',7000,10000 select sn,count(sn)subtotal, name, (datee), sum (sal)salary,sum(bonus) bonus @t group rollup((sn,name, datee)) select sn,count(sn)subtotal, name, (datee), sum (sal)salary,sum(bonus) bonus @t group grouping sets((sn,name ,datee), ())
Comments
Post a Comment