Solved

MS SQL Insert Through Select Statement

Posted on 2006-07-04
1
396 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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

This article explains all about SQL Server Piecemeal Restore with examples in step by step manner.
Many companies are looking to get out of the datacenter business and to services like Microsoft Azure to provide Infrastructure as a Service (IaaS) solutions for legacy client server workloads, rather than continuing to make capital investments in h…
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…

760 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now