I have users table and a followers table. I’m doing a search to get all the users with a specific keyword, but I want the ones which are followers of the current user to appear first. I can get all the followers id’s in a subquery, so my idea was to do something like this: I’ve been trying to get
Oracle SQL conditional operator explanation
Please, may I ask if anyone can explain more on the following oracle sql conditional operator please ? I only have limited oracle sql knowledge that it exclude checking for Sat and sometime for Sunday. Thanks so much! Answer The decode is basically checking the day of the week and returns some magic number = 4, which seems to be
subtract certain date from two dates
Let’s say it is announced that 4 Aug 2022 is a public holiday. I have a table which shows the holiday_start and holiday_end dates. How do I exclude this date “4 Aug 2022” by inputting any date i want (bind variable) and showing it as excluded day eg. leave is from 01-Aug-2022 -> 10-Aug-2022 excluded days= 1 i’ve tried this:
With which order SQL update rows
Let’s say for example we have the following table: Salary table: id name sex salary 1 A m 2500 2 B f 1500 3 C m 5500 4 D f 500 If I write such query that swaps values from the column sex where m should be f and f should be m this query works: I’m used to some
Selecting record that fulfills a condition but don’t want to consider the condition, need to consider the other records thats being matched
im practicing with SQL and have created this table in MySQL: with this insert data how i can check what other content(PROGRAM_FULL_TITLE) watched those that streamed a program, for example, Loki? based on the 2 last insert(ACCOUNT_ID = ‘6ab3c’) in this case, i mean, i wanna show ‘Avengers End Game’ and not i was trying something like this: i search
Basic SQL joining two select statements
I have two select statements that work just fine separately, but I don’t know how to put them together into one resulting table. I’ve been trying SELECT INTO or creating temporary tables, but I am just not getting anywhere. Hoping that if I post the two select statements below, it’ll take someone 30 seconds to point me in the right
Need to combine and get results
I’m trying to do the following: I want to minus the amount of RMAs from Sales: This is the query I did for Sales: This is the one I did for RMAs: I would like to take the results (let’s say 5000 sales and 3000 rma) and return a formatted result. Can you please help? Thanks!! Answer You can jojn
Restrict “subcategory” based on other “category” column
I’m creating a SQLite database where I have 3 tables: transactions, categories, sub-categories in the transactions table, there is a column “category” with a foreign key to the categories table in the sub-categories table, there is column “parent-category” with a foreign key to the categories table Now, how can I ensure that the sub-category that I fill in with transactions
Querying latest snapshot partition with Athena
I have a partitioned table with daily snapshots from from glue. When I use athena to query it queries across all partitions. Is there a way to get Athena to automatically only get the latest snapshot? Or do I have to explicitly state what partition I want to query if I want to avoid querying across all snapshots? Answer If
SQL: How to search set datatype by array?
I want to know if the data exist in set datatype by using an array. For example: The table is $role = [‘a’] SQL = SELECT * FROM … WHERE $role in role (have ‘a’) And the result is Or $role = [‘a’,’b’] SQL = SELECT * FROM … WHERE $role in role (have ‘a’ and ‘b’) And the result