| Author |
Topic |
|
papershop
Starting Member
27 Posts |
Posted - 2011-08-11 : 05:44:37
|
dear alli have sintax : ...select line, familyname, isnull([1],0) as Jan ,isnull([2],0) as Feb ,isnull([3],0) as Mar,isnull([1],0)+isnull([2],0)+isnull([3],0) as Q1, isnull([4],0) as Apr, isnull([5],0) as Mei, isnull([6],0) as Jun, isnull([4],0)+isnull([5],0)+isnull([6],0) as Q2,isnull([7],0) as Jul,isnull( ,0) as Aug,isnull([9],0) as Sep,isnull([7],0)+isnull( ,0)+isnull([9],0) as Q3, isnull([10],0) as Okt, isnull([11],0) as Nov, isnull([12],0) as Dec, isnull([10],0)+isnull([11],0)+isnull([12],0) as Q4from (select line,_month, familyname, valuenet from dbo.v_fact_salesWHERE (_Year = YEAR(GETDATE())-1))uppivot (sum(valuenet) for _month in ([1],[2],[3],[4],[5],[6],[7], ,[9],[10],[11],[12]) )as pvtorder by lineand with this sintax i have data :line product sales Jan sales Feb sales MarAI fgl 763660298 695205829 975460094AI sf 1457229486 1842005461 1484741422AI ds 1663809803 1200154719 1726119190AI sd 146921335 110756898 134292994AI we 295428173 238081171 359766957AI fdas 847919896 772739367 974749461C1 ew 3393074019 2657642701 3401683963C1 cv 196044717 421898144 358896980C1 s 76360038 89527464 96316303C1 dd 107493696 93201840 119578032C1 sdf 781488479 770760549 937287297C2 sdf 0 0 0C2 sf 143887226 199108783 254632999C2 sadf 7230148602 5181272359 6800802345what should i do..in my sintax if i want to add sub total by line?help me please@papershop |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-08-11 : 08:23:05
|
| isnt it matter of adding all the values.------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
jcelko
Esteemed SQL Purist
547 Posts |
Posted - 2011-08-11 : 19:51:07
|
| Every SQL forum or newsgroup expects that you will post DDL, sample data and clear specifications which might might include output. This is explained in the FAQ section. We can not read minds; what would we need to know to do your job for you? Tables must have keys and should have DRI, constraints, and all the basic features of a schema. You should know use ISO-8601 Standards for temporal data, avoid needless dialect, basic data modeling and use ISO-11179 Standards for data element names. Please tell us if you can change the DDL. What you posted is not even normalized!--CELKO--Books in Celko Series for Morgan-Kaufmann PublishingAnalytics and OLAP in SQLData and Databases: Concepts in Practice Data, Measurements and Standards in SQLSQL for SmartiesSQL Programming Style SQL Puzzles and Answers Thinking in SetsTrees and Hierarchies in SQL |
 |
|
|
russell
Pyro-ma-ni-yak
5072 Posts |
Posted - 2011-08-12 : 00:06:38
|
| Celko. Go away. You have nothing constructive to offer. If I was admin on this site, you'd be banned. Tell ya what...I AM an admin on SQL Mag. Post this crap there and I'll ban you in an instant. |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2011-08-12 : 03:57:57
|
quote: what should i do..in my sintax if i want to add sub total by line?
Please show us how is the expected result looks like KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
|
|
|