SQL: how to write a query to find out which columns contain a certain value - sql

the data has over 50 columns, there is one or multiple columns which contain a value, say "US". and i want to find out the columns names. I can check column one by one, but it is time consuming. Anyone has an efficient way to do it? thank you so much!

Related

Delete duplicates excluding columns

I am trying to delete duplicates from an internal table, comparing all columns excluding some of them. Obviously I can list all the columns that I want to compare using COMPARING, but this would not look good in code.
So let's say there are 100 columns and I want to exclude from the comparing 2.
How can I achieve that with a smart way?
You could use the DELETE ADJUSTMENT DUPLICATES operator, there you can define which columns you compare. You'll just have to sort the itab before this operation.

How to go to a specific column in sql

My requirement is simple...
I have a table in SQL with more than 300 columns in it and I need to compare the data present in those columns with the source table.
Now every time I cannot waste my time finding where is the column I want to compare the data by dragging.
So my question is...Is there any short cut or code to go to a specific column when in case of a large table as in my requirement.
Any help is highly appreciated.
There are multiple ways to compare two tables based on the requirement.
If your source can be accessible for you then simple MINUS will do.
In Oracle:
SELECT COL1,COL2,COL3.... FROM SOURCE
MINUS
SELECT COL1,COL2,COL3.... FROM TARGET
In Informatica you can generate MD5 hash for the column you want to compare from both Source and Target and check whether both hashes are matching.

Transpose query using SQL query

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.

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.