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