try to have a single row view from several tables in group by in view - sql

The is one to many relation between first column in first table to first columns for the next two tables
When I make a view with union all between the three tables I can’t have a one row result because the value fields with the yellow color are group by.
The best result I get is to select first() in the yellow column of first table and 0 in the others but I see this as source of error and the result not a single row.
What I can do in the view to have a single row result like this
a pictures for the three table

Related

How to reorganise a table basis a criteria

I have a table where columns exist at different rows as shown in Problem figure.
I am able to identify the rows of column headers (Numbered 1 in column A) and there values(Numbered 2,3 onwards in Column A).
I want collate it in a neat table as shown in Solution table; where all Column headers are in one row and subsequently we have their values.
Problem and expected results are as shown in picture

Merge or Union tables in Access

I have two tables that I would like to combine into an unduplicated list. I have a 'SUB' table that has a 1 column named 'ID' containing a unique identifier for 11,000 some records. I also have another table with 75,000 rows called 'MASTER'. It contains two columns, 'ID' which has the same unique identifier and 'CODE' which contains a unique code for each ID. I want to create a new table that has the 11,000 IDs from the 'SUB' table with the corresponding 'CODE's that match the 'SUB' IDs from the 'MASTER' table. I have used a basic UNION Query, but the results had duplication in the 'ID' column. I tried to consolidate the table produced by that query using Excel, but the list was too long to crunch. Any help? I know this is a basic, but I am not a database person... What would the SQL code look like to achieve this?
Thanks!
You should use JOIN instead of UNION to achieve what you want.
Something like that should work:
SELECT SUB.ID, MASTER.CODE
FROM SUB
JOIN MASTER
ON SUB.ID = MASTER.ID
In general, JOIN allows you to match some rows from one table to the rows from other table according to the value(s) in these rows (think of it as "gluing" rows together along the vertical axis to form longer rows), while what UNION does is just adding all rows from one table below other table (i.e. appends one table to the end of other table along the horizontal axis).

How to append new columns with data from one table to another

I know the title might seem confusing but the real situation is as follow: I have two tables with existing data and both of them have n rows but different columns. The order of the rows in two tables do match. So the goal is such that after appending, the first row of the second table is appended to the first row of the first table, etc. and all the columns from the second table are added to the first table - basically just like paste two tables together.

Select single row from database table with one field different and all other being same

I have a database table with 8 fields say Table(a,b,c,d,e,f,g,h).For some rows one of the field is different(say 4 different a values) while all other field values(b-h) in the schema are same.I have to make a table selecting just one rows from such rows with different a's but same b-h.That is I can select any one of the different a's and keep b-h same which they are and display it in table as 1 single row instead of 4.
SELECT MIN(a) a,b,c,d,e,f,g,h
FROM mytable
GROUP BY b,c,d,e,f,g,h

Get fields from one column to another in Access

Below i have a table where i need to get fields from one column to three columns.
This is how i would like the data to end up
Column1
Music
Column2
com.sec.android.app.music
Column3
com.sec.android.app.music.MusicActionTabActivity
Give the table a numeric autonumber id
Remove the rows with no data with a select where blank spaces or null
Find records with no point in the content with a select
Use the previous query as a source and use the id to find the id + 1 to find the next record and do the same with + 2 to find the second row
Build a table to hold the new structure and use the query as a source to insert the new created data in the new table with the 3 columns structure.
This is an example using sql server
Test table design
Data in table
Query
Look at the query from the inside. The first query inside clean the null records. Then the second query find the records with out point. This records are the reference to find the related two records. Then the id of the records with out point are used to make a query in the select adding 1 for the next record and then other query adding 2 to find the other record. Now you only need to create a table to insert this data, using this query as the source.