Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


how to Update table Sales_summary with max(sales) data from
table sales_dataTable 1. sales_data table Table 2.
Sales_summary

Region sales Region sales
N 500 N 0
N 800 W 0
N 600
W 899
W 458
W 900

I want the Sales_summary After Update like this
Region Sales
N 800
W 900


Answers were Sorted based on User's Feedback



how to Update table Sales_summary with max(sales) data from table sales_dataTable 1. sales_data ta..

Answer / soma

Update Sales_summary set sales = s2.sales
From Sales_summary s1,
(
Select Region, max(sales) sales
From sales_data group by Region
)s2
where s1.Region = s2.Region;

Is This Answer Correct ?    3 Yes 0 No

how to Update table Sales_summary with max(sales) data from table sales_dataTable 1. sales_data ta..

Answer / ajitnayak

update sales_sum s set sales =
(select max(sales) from sales_sum s2 where s.REGIN = s2.REGIN group by REGIN );

Is This Answer Correct ?    2 Yes 0 No

how to Update table Sales_summary with max(sales) data from table sales_dataTable 1. sales_data ta..

Answer / krishna

SQL> desc a;
Name Null? Type
------------------------------- -------- ----
A VARCHAR2(2)
B NUMBER(3)

SQL> select * from a;

A B
-- ---------
N 500
N 800
N 600
W 899
W 458
W 900

6 rows selected.

SQL> desc b;
Name Null? Type
------------------------------- -------- ----
A VARCHAR2(2)
B NUMBER(3)

SQL> select * from b;

no rows selected

SQL> insert into b (select a, max(b) from a group by a);

2 rows created.

SQL> select * from b;

A B
-- ---------
N 800
W 900

SQL>

Is This Answer Correct ?    3 Yes 2 No

how to Update table Sales_summary with max(sales) data from table sales_dataTable 1. sales_data ta..

Answer / sunil

-- It can be done by simple procedure


DELIMITER $$
drop procedure if exists updatesale$$
create procedure updatesale()
BEGIN
declare l_loop_end INT default 0;
declare l_region varchar(10);
declare l_sale int ;

declare cur_1 cursor for select region 'Region',max(sales)
'SALES' from sales_data group by region;
declare continue handler for sqlstate '02000' set l_loop_end
= 1;

open cur_1;

repeat

fetch cur_1 into l_region,l_sale;

if not l_loop_end then
update sales_summery set sales=l_sale where region=l_region;
end if;
until l_loop_end end repeat;
close cur_1;
end$$
DELIMITER ;



call updatesale;

-- now check
select * From sales_summery;

region sales
w 900
N 800

Is This Answer Correct ?    1 Yes 0 No

how to Update table Sales_summary with max(sales) data from table sales_dataTable 1. sales_data ta..

Answer / rm

The question is to Fetch max(sales) from sales_data
and with this value update the sales column
in the sales_summary table.

Is This Answer Correct ?    0 Yes 0 No

how to Update table Sales_summary with max(sales) data from table sales_dataTable 1. sales_data ta..

Answer / keerthi

update Sales_summary
set Sales=(select max(Sales)from Sales_data where
Region=&region) where Region=&region;

Is This Answer Correct ?    0 Yes 1 No

how to Update table Sales_summary with max(sales) data from table sales_dataTable 1. sales_data ta..

Answer / rm

it is a challenging question to any one

Is This Answer Correct ?    0 Yes 1 No

how to Update table Sales_summary with max(sales) data from table sales_dataTable 1. sales_data ta..

Answer / vipul garg

Update Sales_summary s1 set sales =
(
Select max(sales) sales
From sales_data s2
where s1.Region = s2.Region
);

Is This Answer Correct ?    0 Yes 1 No

Post New Answer

More SQL PLSQL Interview Questions

How do I audit the sql sent to the server?

0 Answers  


Hi all, i have a table as follows empid empname mgrid deptid 1 a 3 4 2 b 1 5 3 c 2 3 4 d 3 6 5 e 4 7 i want the output as empname mgrname a c b a c b d c e d

4 Answers  


How much ram can sql express use?

0 Answers  


What are the basic techniques of indexing?

0 Answers  


Write a query to genarate target column.Please answer me. Advance Thanks. Src Tgt Q10 Quarter to 2010 Q90 Quarter to 1990 Q80 Quarter to 1980 Q74 Quarter to 1974

5 Answers   Infosys,


What is the use of nvl function?

0 Answers  


How we get all_group_function's(Sum,avg,count,max and min_value of a column(Sal) Using pl/sql anonymous block, with out using group function's. You shouldn't use more than one select statement in entire the program. Like cursor c is select * from <table_name>; except this you can't use another select statement. You can use no of variables as per requirement.

1 Answers  


How to select unique records from a table?

0 Answers  


how a reference cursor works?what all adnvantages are gained with it..specify the situation?

4 Answers   TCS,


Where not exists in sql?

0 Answers  


Why are cursors used?

0 Answers  


What does 0 mean in sql?

0 Answers  


Categories