Hi, I desperately need help here....
I have 2 tables to start with:
Table1: Data_2009
ID filiale product plan fakt
10 filiale 4 product 1
3 filiale 3 product 1
2 filiale 2 product 1
1 filiale 1 product 1
11 filiale 4 product 2 66 777
6 filiale 3 product 2
5 filiale 2 product 2
4 filiale 1 product 2
12 filiale 4 product 3
9 filiale 3 product 3 22 421
8 filiale 2 product 3 124 124
7 filiale 1 product 3 421 14
Table2: Plani
filiales prod1 prod2
filiale 1 4535 3423
filiale 2 3223 23424
filiale 3 2324 234324
filiale 4 324324 234234
I need to plug in numbers per filiales per products from Table2 into Table1, so blanks in column 'plan' in table A will be filled in.
What I've tried so far:
Union query on Table2:
SELECT filiales as ColHead, "product1" AS RowHead, product1 AS TheVal
FROM plani_po_fil_po _prod
UNION SELECT filiales, "product1",prod uct1
FROM plani_po_fil_po _prod;
UNION SELECT filiales, "product2",prod uct2
FROM plani_po_fil_po _prod;
Then CrosstabQuery on it:
TRANSFORM Avg(plani_trans pose.TheVal) AS AvgOfTheVal
SELECT plani_transpose .RowHead
FROM plani_transpose
GROUP BY plani_transpose .RowHead
PIVOT plani_transpose .ColHead;
Then SelectQuery on the Crosstab (which probabaly wasn't necessary):
SELECT plani_transpose .ColHead AS Filiales, plani_transpose .RowHead AS Produkti, plani_transpose .TheVal AS Plans
FROM plani_transpose ;
This way I get both tables look the same way, but when I try to create Update Query, nothing works...Which would be the right way to go??
Please help!!! file with sample data is attached...
2 1954 ChipR 1,287
Recognized Expert Top Contributor
This is not very elegant, but I believe it will work. Not tested though! - create tempQry
-
SELECT ID, Data_2009.filiale, product, plan, fakt,
-
Plani.prod1, Plani.prod2
-
FROM Data_2009 INNER JOIN Plani
-
ON Data_2009.filiale = Plani.filiales
then - UPDATE tempQry SET plan = [prod1] WHERE product = 'product 1'
and - UPDATE tempQry SET plan = [prod2] WHERE product = 'product 2'
Niccccce!!!!!
Works just fine, and I suppose elegance is not my goal here ;))
The only addition I made was that I added one extra condition so that the records that are already in Table A in column 'plan' don't get overridden by values from Table B...
Thank you so so much for your help!!!!!!!!!!! !!!
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Dan Berlin |
last post by:
I have two tables:
T1 : Key as bigint, Data as char(20) - size: 61M records
T2 : Key as bigint, Data as char(20) - size: 5M records
T2 is the smaller, with 5 million records.
They both have clustered indexes on Key.
I want to do:
|
by: javier garcia - CEBAS |
last post by:
Hi;
I've got problems with a query. I'm not sure if it is possible to do this
with Postgres, although I think it should be.
I had resolved these kind of queryes in MSAccess, where they are called
"cross references querys" but I can't find my way in Postgres.
My table 'muestras_rambla' is like:
date | id_punto | muestra | flow | n_nitrato ...
--------------------------+----------+---------+---------+-----------
|
by: Dom Boyce |
last post by:
Hi
First up, I am using MS Access 2002.
I have a database which records analyst rating changes for a list of
companies on a daily basis. Unfortunately, the database has been set
up (by my predecessor, I hasten to add) so that each day it creates a
copy of the record for each company, changes the date to today's date,
and prompts the user for any changes of ratings on that day. The
resulting data table grows by approx 600 records per...
|
by: Maxi |
last post by:
There is a lotto system which picks 21 numbers every day out of 80
numbers.
I have a table (name:Lotto) with 22 fields (name:Date,P1,P2....P21)
Here is the structure and sample data:
"Date","P1","P2","P3","P4","P5","P6","P7","P8","P9","P10","P11","P12","P13","P14","P15","P16","P17","P18","P19","P20","P21"
1/1/2005,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21
1/2/2005,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22
|
by: Roger |
last post by:
I have a datagrid showing the following....
3114 BUF 3/25/2005 A
3114 BUF 3/24/2005 A
3114 BUF 3/23/2005 B
..
I have transposed this to
Site Ext 3/25/2005 3/24/2005 3/23/2005
3114 Buf A A C
| |
by: Radu |
last post by:
Hi. I have a table with the following *COLUMNS*:
PIN#
# of weeks when Overtime 8
Overtime Week 1
Overtime Week 2
Overtime Week 3
..
..
|
by: issac |
last post by:
Hi folks
Im trying to do a simple query involving the distinct keyword and an
access 2000 db, but have been frittering with it for amost and hour
and a half and I cant make it work.
This is the SQL I would run if it were valid syntax, but it's not:
Select COLOR1, COLOR2, distinct DESC from COLORS;
TABLE COLORS
|
by: CheshireCat |
last post by:
I have added an access database into my 2005 desktop project, created a
dataset called ResourcesDataSet which contains one of each table in the
database using the wizard. The database was automatically copied from its
source directory into my output directory. I connect to it using
Provider=microsoft.jet.oledb.4.0
One of the tables is called server_id which i dragged from the dataset onto
my form.
Visual studio automatically generated...
|
by: ARC |
last post by:
Hello all,
So I'm knee deep in this import utility program, and am coming up with all
sorts of "gotcha's!".
1st off. On a "Find Duplicates Query", does anyone have a good solution for
renaming the duplicate records? My thinking was to take the results of the
duplicate query, and somehow have it number each line where there is a
duplicate (tried a groups query, but "count" won't work), then do an update
query to change the duplicate to...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |