Transpose query using SQL query - sql

I am currently having one problem and I need your help. In my data table, I have one column contains all information that I need, but it has json type. Hence, I have to use SQL query to parse these information.
However, those information now becomes several columns, and that's not what I need. So, may I ask if I want to change these information into rows, which mean transpose the table result, what function should I use? Thanks in advance. My table result contains several rows and several columns.

Related

SQLite data comparison on two tables with 2 million rows of data

I've been trying to find a way of comparing huge amount of data in two different tables but I am not sure if this is the correct approach.
So, this is why I am asking it here to understand a problem more and getting some clarity in order to solve it.
As title says I have two tables with less than 2 million rows of data and I need to a data comparison on them. So basically I only need to check if data in one table matches the data from other tables. Each table comes from separate database and I've managed to create views in order to have the same column names.
Here is my approach which gives me differences from two tables.
SELECT db1.ADDRESS_ID, db1.address
FROM UAT_CUSTOMERS_DB1 db1
EXCEPT
SELECT db2.ADDRESS_ID, db2.address
FROM UAT_CUSTOMERS_DB2 db2;
I have two questions, so basically this works:
It seems pretty straightforward but can someone explain to me in a bit more depth how this query works with such speed ? Yes I know - read docs but I would really appreciate alternative answer.
How can I include all the columns from tables without specifying manually each column name ?

random sample results for access sql query

I have a table with a column called names, it is meant for there to be several rows with the same name. I need to find a way to make a query to give as result a 4% random sample of the rows with every name using Access SQL syntax. For example, if there are 100 rows of each name in the table, for it to return 4 random rows for each name on that column. Does that make sense?
I'm not very experienced on Access SQL and SQL in general, yet. Any guidance will be greatly appreciated!!!!! :)
This material might be helpful
http://support.microsoft.com/kb/153747/en-us

Dynamic Dataset updation

I am creating a project in VB.NET in which one of the reports require that the name of employees should be displayed as column names and whatever work they have done for a stated period should appear in rows below that particular column.
Now as it is clear, the columns will have to be added at runtime. Am using an ODBC Data source to populate the grid. Also since a loop will have to be done to find out the work done by employees individually, so the number of rows under one column might be less or more than the rows in the next column.
Is there a way to create an empty data table and then update its contents based on columns and not add data based on addition of new rows.
Regards
A table consists of rows and columns: the rows hold the data, the columns define the data.
So you have no other choice than to add at least that many rows as your longest column will need. You could just fill up empty values in the other columns. That should give you the view you need.
Wouldn't it be better to simply switch the table orientation?
If most of your columns are names or maybe regroupment I dont' know,
then you'd have one column for each of the data you could display,
And you'd add each rows with the names and stats dynamically, which is more common.
I'm only suggesting that, because I don't know all your table structure.

Can a Column in a table pick up data from Another Table in SQL Server

I have a table PatientChartImages. It has a column ChartImage, which contains the binary of images. Now, we are planning to create a separate table which will contain the Binary of Images and will join both the tables to get requisite data. Now, we do not want to change the front end and I cannot use triggers. So, is there any way by which if a query refers to ChartImage column of PatientChartImages, it picks data from the third table? Please suggest.
I think inner-join does this. I've only overheard it's use - but this might lead you towards your answer.

SQL How to find out what tables have a certain column

Is it possible to construct a query so that I can find out what tables have a particular column? Then if it has the column query that table for an ID number? Is this possible?
Sure, I think you can look at the contents of the X$Field system table, described here:
http://ww1.pervasive.com/library/docs/psql/794/sqlref/sqlsystb.html