I want to connect multiple data sources (Oracle, MySql etc) and databases. Then I want to create a table in Qlikview based on the result set of multiple select queries from the different databases.
How can we do this?
Hi the easiest is to create separate ODBC connections in Windows:
Then in Qlivkiew script before SELECT we have to specify which connection we want to use:
ODBC CONNECT TO [Connection Name];
If you create the results tables to have exactly the same column names then Qlik will automatically concatenate those tables.
So
ODBC [ORACLE];
SALES:
Select TransNum as OrderId,
Amount
from xxxxxx;
odbc [other SQL];
Select OrderId,
Value as Amount
from yyyyy;
load OrderId,
Amount
from zzzzz.xls;
Will result in one table called SALES with the 2 columns OrderId and Amount
Related
I have 2 different SQL databases "IM" and "TR". These have different schemas.
IM has the table "BAL" which has 2 columns "Account" and "Balance".
TR has the table "POS" which has 2 columns "AccountId" and "Position".
Here the common link is BAL.Account=POS.AccountId.
The POS table has > 100k records. BAL has few only records as it shows only accounts which are new.
I want to run a select query on IM Databases' BAL table as follows:
Database: IM
Select Account, Balance from BAL
However, here the "Balance" should return the results from TR Database POS.Position based on BAL.Account=POS.AccountId
How can I achieve this in the fastest manner by not slowing the databases and considering that this query will be executed by lot of users every now and then. Should I use OPENQUERY? I will use where clause to shorten the return time.
I need to merge two tables in sqlite based on a common column. The problem is both the tables belong to different databases. So, what would be an efficient way to merge the tables here?
A sample table would be like this with the desired result. But the problem is these two tables are in different databases.
Table 1: Employee_Pro_Profile
Columns: Emp_Id, Emp_Name, Emp_Sal
Table 2: Employee_Personal_Profile
Columns: Emp_Id, Emp_Home_Address, Emp_Phone
Resulting Table: Employee_Complete
Columns: Emp_Id, Emp_Name, Emp_Sal, Emp_Home_Address, Emp_Phone
Okey first you have to attach the databases, to your current connection.
SQLite give you this by using ATTACH.
The ATTACH DATABASE statement adds another database file to the current database connection.
ATTACH LINK
Run this:
attach database DatabaseA.db as DbA;
attach database DatabaseB.db as DbB;
Now you can reference the databases as you do with tables...
select
*
from
DbA.Table1 A
inner join
DbB.Table2 B on B.Emp_Id = A.Emp_Id;
There is a limit to the number of databases that can be simultaneously attached to a single database connection.
Check your settings if something goes wrong, the flag is:
#define SQLITE_LIMIT_ATTACHED 7
// SQLITE_LIMIT_ATTACHED - The maximum number of attached databases.
I have a SQL Server table that has a unique field which matches a unique field in an Access DB table.
I need to get the Access DB table into the SQL Server table based on that field.
How do I go about doing this?
I want to say a JOIN, but a JOIN is just a temporary query, isn't it? I want this to be permanent. I want the Access DB table data merged into SQL Server table based on this unique field.
What's the best way to do this?
Thanks.
The reason I need this separate is that a software is reading this SQL Server data, so I need it all in the same table.
B,
I believe what you would be looking for is Union
With the two tables being
HumanResources.Employees and HumanResources.Employees2
SELECT ID, Name FROM HumanResources.Employees
UNION
SELECT ID, Name FROM HumanResources.Employees2
I have a little bit of a challenge. I have to consolidate some data that is coming from three different databases (Oracle, SQL Server, and Teradata).
How can I retrieve the data from TeraData and SQL Server based on the retrieve from Oracle?
For instance, Oracle has the sales information, TeraData has the client information, and SQL Server has the employee information.
I pull the list of sales from Oracle which has a list of client IDs and want to limit the TeraData pull based on those client IDs.
The clients then have an Employee identifier that ties to SQL Server.
I can connect to each individually but would like to limit the pulls from each.
Oracle returns about 3,000 rows while TeraData by itself returns 400,000 rows. The Oracle to TeraData is a many to 1 relationship (many oracle records to 1 TeraData record).
I have tried using the data source merge option but it runs each data source individually then merges them which ends up drastically increasing the amount of processing time due to the amount of records in TeraData.
Your assistance is appreciated. Thanks.
You pass over some SQL with an enormous IN string if you though it would reduce the record count: SELECT Sales.* FROM Teradata.Sales WHERE ClientID IN () You'd need to pre generate a static SQL string from something else before running against Teradata. You might run into SQL length issues if it's large.
Do you have a SQL Statement that retrieves unique client id's from Oracle?
SELECT DISTINCT ClientID FROM SCHEMA.SALES
I'm learning SQL for a while and I'm stuck with this problem.
I have two tables for a storage company.
In one table for the bookings for the whole company consisting booking no., date, product nr., quantity and storage room.
And in one table I have storage facility name and storage rooms to define the room belong to which facility
I want to have the sum of the quantity of one specific product in one specific storage facility
SELECT sum(Quantity) from Bookings where ProductNo=8888 and Storage.StorageFacility="Central"
Do I have to use a more complex query for the solution?
Your storage facility is in a different table than the BOOKINGS table (and they are related via STORAGE_ROOM). So you need to join these tables:
select sum(Quantity)
from bookings b
join storage_facility_details sfd
on b.storage_room = sfd.storage_room
where sfd.storage_facility = 'x'
and bookings.productno='8888'
The syntax of SQL can be slightly different on different database systems. Usually quotes (") are used to refer to tables and similar objects. Use single quotes (') to give values. Also, all the tables that you refer columns of need to appear after FROM. If the columns quantity and storagefacility appear in both tables you need to fully quality the name.
Also you need to join the two tables on a column, so the productno must also be present in your storage table.
SELECT sum(quantity) FROM bookings, storage
WHERE (bookings.productno = storage.productno)
AND
(bookings.productno='8888' AND storage.storagefacility='Central');