Solved

MS SQL Insert Through Select Statement

Posted on 2006-07-04
1
414 Views
Last Modified: 2008-03-06
Sir, I am using following command to insert some information from an other table

Insert Into BrcOffExp(ExpDate,Discriptions,credit) values (select x.ExpDate,x.JobNo,x.Amount
from
(select ExpDate=max(a.cbd),JobNo='Job # ' + left(a.file_job,5) + 'Peshawar Expense', Amount=sum(a.RahdariCost)+sum(a.TurkhamClearanceExp)
from cntrtransporterdet a
where a.cbd >='06/01/2006'
and a.Cbd <='06/30/2006'
group by a.file_job)x
where amount > 0


Please let me know where i am doing mistake because it is showing error on line first near select.

Rgds.
Mehram
0
Comment
Question by:Mehram
1 Comment
 
LVL 75

Accepted Solution

by:
Aneesh Retnakaran earned 500 total points
ID: 17035470
Hi Mehram,
Insert Into BrcOffExp(ExpDate,Discriptions,credit)
select x.ExpDate,x.JobNo,x.Amount
from
(
select ExpDate=max(a.cbd),JobNo='Job # ' + left(a.file_job,5) + 'Peshawar Expense',
Amount=sum(a.RahdariCost)+sum(a.TurkhamClearanceExp)
from cntrtransporterdet a
where a.cbd >='06/01/2006'
and a.Cbd <='06/30/2006'
group by a.file_job)x
where amount > 0


Cheers!
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I guess that all of us know that caching the data usually increase the performance, but I worried if all of us are aware about the risk that caching the data provides and how to minimize this.  That’s the reason why I decided to write this short art…
APEX (Application Express) is used to develop a web application from Oracle. SQL Workshop is one of the tools that comes with Oracle APEX to query or modify the database objects or to make any changes to the structure.
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question