I am trying to select the record but not getting the record I wanted. here is my sqlfiddle http://sqlfiddle.com/#!17/5296a/1 so when I selects the record using below query it gives me result with the title DDDDD. it should give me GGGGGGGG. I wanted to check if there is any record with author_id=3 and greater…
Tag: sql
How can I get a value when the master table of the outer join is empty?
I have created a table where I get the sum of each item. However, this query returns : 0 row affected. I know what the problem is. If the key_id and cust_id are not in the t1 table specified as an alias, the value cannot be returned because the t1 table is empty. If there is data for key_id in
Delete unused groups in Laravel 8
I have a group model and I want to delete groups that don’t have any member. How can I get empty groups with eloquent or SQL query ? And this is the User model code: Answer I think whereDoesntHave work in you situation.
SQL queries for calculating shipping charges based on subtotal amount [closed]
Closed. This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 1 year ago. Improve this question ID Name min_amount charge 1 Standard 50.00 3.00 2 Express 50.00 5.00 3 Standard 100.00 2.00 4…
How can I make the trigger return a value?
I have a ‘roomstate’ table that represents states that I keep updated. This is what happens when the employee assigns room 2 to customer 1 whose booking_id is 2. As the table above is continuously updated, the existing contents may become NULL again. I’d like to have a record of updating thi…
Redshift : Coalesce Can’t Work As Expected
We’re complementing null value to all zero value like ’00’ on Redshift. Sometimes, I found coalesce function can’t work as we expected. If we use case and len, it can work fine as follows; So far, I have no idea why coalesce can’t work. Any advice would be appreciated. Thank you.…
optionally enclosed not working, commas breaking upload
I have this table: Here is my load statement: In spend I’ll have a decimal value with a comma like: 1193.72. The spend field gets uploaded as 1. The impressions field that follows is correct and unaffected. Example record: 1/19/2021 | 1,193.72 | 92780 Output: 1/19/2021 | 1 | 92780 I was under the impres…
SQL subquery in SELECT clause
I’m trying to find admin activity within the last 30 days. The accounts table stores the user data (username, password, etc.) At the end of each day, if a user had logged in, it will create a new entry in the player_history table with their updated data. This is so we can track progress over time. accou…
while Convert sql query to json getting wrong output
I am getting wrong output Output should be: Answer The problem is with your nested loops. You actually want to parallely iterate both lists. The lists themselves are quite complex due to the nesting of lists and tuples. That’s why you may loose track here. You could try simplifying the lists/objects if …
Using NVL with JOIN
I want to display 2 values in table but only Student 301 is displayed. Student 102 doesn’t received any grades. I joined two tables. Here’s my query. Thanks for your help Answer Presumably, both students are in enrollment_info. If so, you can use: Note the use of LEFT JOIN. The table where you wan…