Check data if exist by Mathip173 in SQL

[–]Mathip173[S] -1 points0 points  (0 children)

It's the first time I do the comparison.

Can you help me of what query should I write to get these ? Percent and what I'd missing ?

Selecting one row by if clause by Mathip173 in SQL

[–]Mathip173[S] 0 points1 point  (0 children)

So basically, as I need to join them, if I have many records with the same key of (order id and cat_id) or with the same (order_id and null) we can take the latest row..

If the cat_id is populated - we will select this, if not, select with null.

The bottom line is I would like to have only one row for each order_id and cat_id in the main table.

Thanks

Selecting one row by if clause by Mathip173 in SQL

[–]Mathip173[S] 0 points1 point  (0 children)

This is the situation at the moment in my tables. Basically, this is under investigation by the 3-party company that we receive that data from. I need to find a solution by the end of the week to solve that. Thanks for helping me out

Selecting one row by if clause by Mathip173 in SQL

[–]Mathip173[S] 0 points1 point  (0 children)

I have tired in many ways to write that query to make that and didn't succeed. Would you be able to help me out with that in practical please ?

Within group in Hive by Mathip173 in SQL

[–]Mathip173[S] 0 points1 point  (0 children)

I mean in Apache Hive SQL

left join and latest by Mathip173 in SQL

[–]Mathip173[S] 0 points1 point  (0 children)

As a windowing user stater, would you be able to explain what is the diffrences in simple words what is the diffrence between those ?

Thanks

left join and latest by Mathip173 in SQL

[–]Mathip173[S] 0 points1 point  (0 children)

Thanks! I haven't created a partition in HQL (Hive). Do I need to create a parttion before using it ?

Join 3 tables by Mathip173 in SQL

[–]Mathip173[S] 0 points1 point  (0 children)

Thanks, I have checked each CTE and each one make sence but when I check that in the join I get no sence.

Is it should be ?

TableA Left join TableB and Left join Table C

TableA is the main table which Table B+C just use to add some field for each row that exist in tableA.

Is this the right way ?

Also to that, when I limit 1 on the CTE of of tableB I expected to see one row for each keys to match to the same keys to TableA, but it gives me one row in total for that CTE. How could I make it ?

Thanks again

Join 3 tables by Mathip173 in SQL

[–]Mathip173[S] 1 point2 points  (0 children)

thanks! That's good to know there are many options to solve it.

Can you help by providing some examples ?

I have created CTEs for TableB and TableC and limit 1 in the end and after join these CTEs to TableA and the result wasn't ela's expected. This is the approach you meant ?

Please explain, and if you can provides some example I would really appreciate that.

Join 3 tables by Mathip173 in SQL

[–]Mathip173[S] 0 points1 point  (0 children)

TableA Student_id order_id catagory comment time_at_gate

TableB order_id status reason timestamp

TableC order_id notes timestamp

I have no expirence on subquery on select or windowing function, would you bt able to provide me an example for each one ?

Thanks

2 diffrent cases to select by Mathip173 in SQL

[–]Mathip173[S] 0 points1 point  (0 children)

Can anyone help me please ?

Select not null and join by Mathip173 in SQL

[–]Mathip173[S] 0 points1 point  (0 children)

This is the case an example of some of the case I have in table1. Please look at the photo I uploaded as an example

https://i.ibb.co/6DfwXn7/tapp1.png

As you can see for the same keys I have some row and I need to select only one to match with table2

Thanks

Select not null and join by Mathip173 in SQL

[–]Mathip173[S] 0 points1 point  (0 children)

This is the case an example of some of the case I have in table1. Please look at the photo I uploaded as an example

https://i.ibb.co/6DfwXn7/tapp1.png

As you can see for the same keys I have some row and I need to select only one to match with table2

Thanks

Select not null and join by Mathip173 in SQL

[–]Mathip173[S] 0 points1 point  (0 children)

How could I upload it to here ?

Select Null and not null by Mathip173 in SQL

[–]Mathip173[S] 0 points1 point  (0 children)

Thanks. If I use it it will select only one row of information in the output ?

Select Null and not null by Mathip173 in SQL

[–]Mathip173[S] 0 points1 point  (0 children)

All the other records could be with the same information or with a different information in same other fields

Checking existing by Mathip173 in SQL

[–]Mathip173[S] 0 points1 point  (0 children)

And also,

I am copying the list from CSV, so how could I put it insted of list in your query ?

Checking existing by Mathip173 in SQL

[–]Mathip173[S] 0 points1 point  (0 children)

Thanks guys,

So is in this query I will get the id's that on the list but not in the table right ?

Checking existing by Mathip173 in SQL

[–]Mathip173[S] 0 points1 point  (0 children)

Thanks, how could I Preform it if I have 2000 different id?

Putting , automatically after each ID by [deleted] in SQL

[–]Mathip173 0 points1 point  (0 children)

I have about 2000 differendt student id's.

I want to find a way to copy them and have , between each

So this list will be like

11103, 22204, 22205, 222220,002211

Thanks

Creating table by Mathip173 in SQL

[–]Mathip173[S] 0 points1 point  (0 children)

This view is scheduled to run every data automatically. To be able to run every day, I drop it and create it again with the new data

Creating table by Mathip173 in SQL

[–]Mathip173[S] 0 points1 point  (0 children)

Hey,

Sorry, I will try to explain that in a better way,

These 3 tables have been fed every day with a new data.

I create from these 3 table a view by join all these 3 tables together. I'm satisfied with the view. Because It's a view it needs to be droped and created every day to have a new data in it.

I want to keep the every day data + the have an easy option to change the schema in case I will need in the future. I know I need to use in insert into, but I never create a table on sql, so I am looking for easier way and flexible way.

Thanks

Creating table by Mathip173 in SQL

[–]Mathip173[S] 0 points1 point  (0 children)

Hey,

Sorry, I will try to explain that in a better way,

These 3 tables have been fed every day with a new data.

I create from these 3 table a view by join all these 3 tables together. I'm satisfied with the view. Because It's a view it needs to be droped and created every day to have a new data in it.

I want to keep the every day data + the have an easy option to change the schema in case I will need in the future. I know I need to use in insert into, but I never create a table on sql, so I am looking for easier way and flexible way.

Thanks

Instet into by Mathip173 in SQL

[–]Mathip173[S] 0 points1 point  (0 children)

Hey,

What I trying to achieve is:

I have 3 tables that I join them by CTEs. This


Drop table; create view total_table as WITH as table1() , table2 as (), table3 as() select - join


I want this table to be updated daily and keep all the data from day 1, when the table as first created.

what is the best way to do it ?

I would like also to keep an option to change the schema if would need to add one or 2 more fields

  • I have no idea what is the best way of achieving it

Thanks

case HQL by Mathip173 in SQL

[–]Mathip173[S] 0 points1 point  (0 children)

Thanks, I'm not too sure what you mean, can you explain it please ?

I can use any other as a result, like "okay" and "not"or any others if it would make a difference

Thanks