Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2006-03-10 : 08:43:37
|
altimebest1 writes "I would like to produce a table like this | code | description | 1999 | | | country |Qty | F value | C value | __________________________________________________ | 001 | Thing1 | 15 | 200 | 200 | | | Japan | 5 | 100 | 100 | | | USA | 5 | 50 | 50 | | | PHI | 5 | 50 | 50 | -------------------------------------------------- | 002 | Thing2 | 20 | 100 | 100 | | | AUS | 10 | 40 | 40 | | | USA | 4 | 30 | 50 | | | CHI | 6 | 30 | 10 | -------------------------------------------------- where c value = fvalue + insurance + freight my source table is code char 7, description varchar 50, countryCode char 3, month, year, qty, fvalue, insurance, freight.I been trying to solve this problem for months but I am new here, I haven't solved it. I hope you can help me on this could you write or show me a link to articles related to my problem.Thank you" |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2006-03-10 : 08:51:48
|
| [code]select code, description, year, sum(qty) as [Qty], sum(fvalue) as [F value], sum(fvalue + insurance + freight) as [C value]from yourtablewhere year = 1999group by code, description, year[/code]----------------------------------'KH' |
 |
|
|
jsmith8858
Dr. Cross Join
7423 Posts |
Posted - 2006-03-10 : 09:31:55
|
| Use a reporting writing tool like Crystal, Access, reporting services. It is very, very easy to write reports like that if you use the proper tool; it is very, very hard and not a good idea to try to do so using a database language like SQL which is not designed to produce pretty, formatted output.If you need help querying some tables to get back the basic data, then let us know. |
 |
|
|
|
|
|
|
|