How to multiply two value from two fields | SQL Server Performance Forums

SQL Server Performance Forum – Threads Archive

How to multiply two value from two fields

I have the following fields in table A: GL_ID|GL_Name_VC | Amount |Period_TI|Year_SI
1000| Inventory| 8,000.00 | 01 | 2005
1000| Inventory| -3,000.00 | 02 | 2005
1000| Inventory| 5,000.00 | 02 | 2005
=================================================== the fields above have the following datatype: Fields | Datatype
GL_ID | Integer
GL_Name_VC | Variable Character
Amount | Integer
Period_TI | TinyInteger
Year_SI | SmallInteger The above database is running on Microsoft SQL Server 2000 and i would like to query
for a report that looks something as below: GL_ID|GL_Name_VC |Period_01|Period_02 |Total_YTD
1000 | Inventory | 8,000 | 2,000 |10,000 Percentage| 10% | 20% | 0
Total | 800 | 400 | 1,200 The Total row is calculated by multiplying the percentage row by the Inventory amount in
each Period. Guys, hope someone out there can help me with the sql command for the above report?

Maybe Im being a little harsh here, but I think the idea of the forums is to help people with a specific problem theyre having, rather as a way for us to do all your work for you for free. Youve just posted 8 topics all asking for various reports. Maybe you should buy a book and learn sql?
Besides that, your specification is not clear enough. What do these 10%, 20% mean? First query is not so simple so I’m going to give you a hint: You should use group by non-agregate columns and 3 sum aggregations. For period totals you have to use case statement. So, find select topic – group by clause in books on-line and also Case operator description.