Updating multiple columns in oracle
Aggregating sales for each weekday or month works fine, but expanding the query to aggregate sales for each week, with a column for each week, would quickly become tedious. Most of the information resides in your local database, but a trip across a gateway to an external, non-Oracle database is required to gather information for parts supplied by Acme Industries.
The round trip from your database through the gateway to the external server and back takes 1.5 seconds on average.
UPDATE The Oracle UPDATE statement locates one or more rows (or all the rows) in a table and sets one or more columns to the specified values.
Consider the following query, which aggregates sales data for each day of the week: SELECT TO_CHAR(order_dt, 'DAY') day_of_week, SUM(sale_price) tot_sales FROM cust_order WHERE sale_price IS NOT NULL GROUP BY TO_CHAR(order_dt, 'DAY') ORDER BY 2 DESC; DAY_OF_WEEK TOT_SALES ------------ ---------- SUNDAY 396 WEDNESDAY 180 MONDAY 112 FRIDAY 50 SATURDAY 50 In order to transform this result set into a single row with seven columns (one for each day in the week), you will need to fabricate a column for each day of the week and, within each column, sum only those records whose order date falls in the desired day.If your database design includes denormalizations, you may run nightly routines to populate the denormalized columns.For example, the The readability advantage of the CASE expression is especially apparent here, since the DECODE version requires three nested levels to implement the same conditional logic handled by a single CASE expression.Notice that the WHERE clause identifies which row will be updated with Oracle UPDATE.SQL Server FAQ SQL Server FAQ - Importance of Column Order in the SET Clause in Update Statements By: (Continued from previous topic...) Is the Order of Columns in the SET Clause Important? The order of columns in the SET clause of the UPDATE statement is NOT important.
999 2006-04-30 -- Update "id" before "counts" UPDATE fyi_links SET id = id 200, counts = id*2 WHERE url = 'dev.fyicenter.com' GO (1 row(s) affected) -- Check the new values SELECT * FROM fyi_links WHERE url = 'dev.fyicenter.com' GO id url notes counts created 301 dev.Good.