Welcome to dbForumz.com!
FAQFAQ    SearchSearch      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

How to do updates upon the query results

 
   Database Forums (Home) -> Datamining RSS
Next:  perl cgi vs php  
Author Message
Mantvydas

External


Since: Jan 22, 2008
Posts: 2



(Msg. 1) Posted: Mon Jan 21, 2008 10:00 pm
Post subject: How to do updates upon the query results
Archived from groups: microsoft>public>sqlserver>datamining (more info?)

Hello,

I've run a complex SELECT statement combined of the several tables, which
returns me:

MemberID MemberName CurrentWeightAvailableOn010108
NeedsToHaveWeightOnDate Modifier(NeedsToHaveWeight-CurrentWeightAvailable)
1 John Doe 100
105 5
6 Yao Ming 120
121 1
9 Adam Waters 110
106 -4

How can I run an update on tblMemberWeight, which is:

MemberWeightID MemberID Date (varchar(10))
WeightAvailable
1 1
01-01-2008 100
2 1
01-02-2008 115
3 1
01-03-2008 102
4 2
01-01-2008 121
5 2
01-02-2008 135
6 2
01-03-2008 92

If I want to update a weight on a single date for multiple members?
(Optional) If I want to update multiple dates in one go, by the same
modifier?

It's SQL2000.

The business problem is, that on the dates of measuring, wrong measures were
taken, and now we need to adjust each day by a certain modifier.

Thank you!
Mantvydas

 >> Stay informed about: How to do updates upon the query results 
Back to top
Login to vote
Dejan Sarka

External


Since: Mar 18, 2004
Posts: 317



(Msg. 2) Posted: Wed Jan 23, 2008 5:08 am
Post subject: Re: How to do updates upon the query results [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

In Books OnLine, there is an example how to update rows in one table using
information from another table:

USE AdventureWorks;
GO
UPDATE Sales.SalesPerson
SET SalesYTD = SalesYTD + SubTotal
FROM Sales.SalesPerson AS sp
JOIN Sales.SalesOrderHeader AS so
ON sp.SalesPersonID = so.SalesPersonID
AND so.OrderDate = (SELECT MAX(OrderDate)
FROM Sales.SalesOrderHeader
WHERE SalesPersonID =
sp.SalesPersonID);
GO

Check the UPDATE (Transact-SQL) topic, I think this is what you need.

--
Dejan Sarka
http://blogs.solidq.com/EN/dsarka/default.aspx

"Mantvydas" <mantvydas at gmail dot com> wrote in message

> Hello,
>
> I've run a complex SELECT statement combined of the several tables, which
> returns me:
>
> MemberID MemberName CurrentWeightAvailableOn010108
> NeedsToHaveWeightOnDate
> Modifier(NeedsToHaveWeight-CurrentWeightAvailable)
> 1 John Doe 100 105
> 5
> 6 Yao Ming 120 121
> 1
> 9 Adam Waters 110
> -4
>
> How can I run an update on tblMemberWeight, which is:
>
> MemberWeightID MemberID Date (varchar(10))
> WeightAvailable
> 1 1 01-01-2008
> 100
> 2 1 01-02-2008
> 115
> 3 1 01-03-2008
> 102
> 4 2 01-01-2008
> 121
> 5 2 01-02-2008
> 135
> 6 2 01-03-2008
> 92
>
> If I want to update a weight on a single date for multiple members?
> (Optional) If I want to update multiple dates in one go, by the same
> modifier?
>
> It's SQL2000.
>
> The business problem is, that on the dates of measuring, wrong measures
> were taken, and now we need to adjust each day by a certain modifier.
>
> Thank you!
> Mantvydas

 >> Stay informed about: How to do updates upon the query results 
Back to top
Login to vote
Mantvydas

External


Since: Jan 22, 2008
Posts: 2



(Msg. 3) Posted: Wed Jan 23, 2008 12:00 pm
Post subject: Re: How to do updates upon the query results [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Thanks, I'll try that.

Mantvydas

"Dejan Sarka" parašė
naujienų
> In Books OnLine, there is an example how to update rows in one table using
> information from another table:
>
> USE AdventureWorks;
> GO
> UPDATE Sales.SalesPerson
> SET SalesYTD = SalesYTD + SubTotal
> FROM Sales.SalesPerson AS sp
> JOIN Sales.SalesOrderHeader AS so
> ON sp.SalesPersonID = so.SalesPersonID
> AND so.OrderDate = (SELECT MAX(OrderDate)
> FROM Sales.SalesOrderHeader
> WHERE SalesPersonID =
> sp.SalesPersonID);
> GO
>
> Check the UPDATE (Transact-SQL) topic, I think this is what you need.
>
> --
> Dejan Sarka
> http://blogs.solidq.com/EN/dsarka/default.aspx
>
> "Mantvydas" <mantvydas at gmail dot com> wrote in message
>
>> Hello,
>>
>> I've run a complex SELECT statement combined of the several tables, which
>> returns me:
>>
>> MemberID MemberName CurrentWeightAvailableOn010108
>> NeedsToHaveWeightOnDate
>> Modifier(NeedsToHaveWeight-CurrentWeightAvailable)
>> 1 John Doe 100 105 5
>> 6 Yao Ming 120 121 1
>> 9 Adam Waters 110 -4
>>
>> How can I run an update on tblMemberWeight, which is:
>>
>> MemberWeightID MemberID Date (varchar(10))
>> WeightAvailable
>> 1 1 01-01-2008 100
>> 2 1 01-02-2008 115
>> 3 1 01-03-2008 102
>> 4 2 01-01-2008 121
>> 5 2 01-02-2008 135
>> 6 2 01-03-2008 92
>>
>> If I want to update a weight on a single date for multiple members?
>> (Optional) If I want to update multiple dates in one go, by the same
>> modifier?
>>
>> It's SQL2000.
>>
>> The business problem is, that on the dates of measuring, wrong measures
>> were taken, and now we need to adjust each day by a certain modifier.
>>
>> Thank you!
>> Mantvydas
>
 >> Stay informed about: How to do updates upon the query results 
Back to top
Login to vote
Display posts from previous:   
Related Topics:
Saving prediction query results to a relational table - How do I save the prediction query results to a relational table outside of the BI studio?

Filtering Prediction results - hello people, I have some association mining models with sql 2005. When i execute a singleton prediction query and my input case cant match any association the results include most popular itens. Is there a way to return only itens with some..

Difference of mining results -

Comparing Data and Filtering Results - shopper_tracking shopper_id tracking_num closed date_entered 12345 1za45690987 1 8/15/2005 65984 1za45690988 1 8/15/2005 23569 1za45690990 1 8/15/2005 25648 1za45690991 ...

Data Mining Training gives me no results - Hi, I am studying data mining features of SSAS and for a workshop I've created 2 views derived from vTargetMail view of AdventureWorksDW. Train data consists every record except those in Pacific, and test view consists only records from Pacific area. 1....
   Database Forums (Home) -> Datamining All times are: Pacific Time (US & Canada)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You can edit your posts in this forum
You can delete your posts in this forum
You can vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]