How JustAnswer Works:
  • Ask an Expert
    Experts are full of valuable knowledge and are ready to help with any question. Credentials confirmed by a Fortune 500 verification firm.
  • Get a Professional Answer
    Via email, text message, or notification as you wait on our site. Ask follow up questions if you need to.
  • 100% Satisfaction Guarantee
    Rate the answer you receive.
Ask ATLPROG Your Own Question
ATLPROG
ATLPROG, Computer Software Engineer
Category: Programming
Satisfied Customers: 7260
Experience:  MS in IT.Several years of programming experience in Java C++ C C# Python VB Javascript HTML
44910485
Type Your Programming Question Here...
ATLPROG is online now

In T-SQL i need to get totals based on the following

Customer Question

Hi, In T-SQL i need to get totals based on the following request. Screenshot attached. What i need to to do is..

1. In row 6, Sales Total, GL_Account_No 11005, currently = null in the 'Amount' column. NULL needs to be replaced with the sum total amount where GL_Account_No = 11000, 11001, 1002, 11003, 1104.

2. In row 10, COST OF SALES , GL_Account_No 11203, currently = null in the 'Amount' column. NULL needs to be replaced with the sum total amount where GL_Account_No = 11200, 11201, 11202.

3. In row 11, GROSS PROFIT , GL_Account_No 11300, currently = null in the 'Amount' column. NULL needs to be replaced with the SALES TOTAL amount minus COST OF SALES amount.

4. In row 12, GROSS PROFIT %, GL_Account_No 11301, currently = null in the 'Amount' column. NULL needs to be replaced with the GROSS PROFIT amount divided by SALES TOTAL amount.

Attachment: 2016-06-05_154346_finmodelv2.xlsx

Submitted: 1 year ago.
Category: Programming
Expert:  Ingo U replied 1 year ago.

Hi,

are you just looking for a query to just generate the output as you described, or do you want the resulting values (where there are currently NULLs) also to be stored back in the AMOUNT field of their database record?

Customer: replied 1 year ago.

Hi,

Ideally i'd like the query to be incorporated into a 'select into' statement, so yes also be stored back in the amount field.

EG.

SELECT
GL_Account_Name,
GL_Account_No,
AMOUNT

INTO TABLE_A
FROM TABLE_B

Thanks