Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Troubleshooting
Research
Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

URGENT- t-SQL SUM problem

Avatar of innocent1973
innocent1973 asked on
Microsoft SQL Server 2005
23 Comments1 Solution360 ViewsLast Modified:
Hello Experts
I have inserted a table structure, some data and my query as below.
But there is a problem on line:
SELECT  m.smodel,c.smodel AS col,m.lIlaveMaliyetTutar * c.lbrutfiyat/1000 AS RESULT

I want to replace the value as SUM(lbrutfiyat). Because this value is the sum of lbrufiyat columns for a specific lfisno.

Please help
create table erdem_fistipleri2
(
smodel varchar(50),
lfisno varchar(50),
nstoktipi int,
sfistipi char(50),
lbrutfiyat float,
lIlaveMaliyetTutar float
)
******************************************************


INSERT INTO erdem_fistipleri2 values('XXXXXXXX','9999999',2,'FA',1,166.67)
GO 
UNION ALL
INSERT INTO mytest values('159 010 100','9999999',4,'HA',100,0)
GO 
UNION ALL
INSERT INTO mytest values('159 010 106','9999999',4,'HA',500,0)
GO 
UNION ALL
INSERT INTO mytest values('159 010 105','9999999',4,'HA',400,0)
GO 
UNION ALL
INSERT INTO mytest values('YYYYYYYY','9999999',2,'FA',5,833.33)
GO 
***************************************************


SELECT  m.smodel,c.smodel AS col,m.lIlaveMaliyetTutar * c.lbrutfiyat/1000 AS RESULT
INTO #subresults
FROM    erdem_fistipleri2 m
CROSS APPLY 
(
        SELECT  smodel,lbrutfiyat
        FROM    erdem_fistipleri2 c
        WHERE sfistipi='HA'
)c
WHERE m.sfistipi='FA'
ASKER CERTIFIED SOLUTION
Avatar of RiteshShah
RiteshShahFlag of India image

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Commented:
This problem has been solved!
Unlock 1 Answer and 23 Comments.
See Answers