I have a problem where I have two tables. One table constains urls and their information and another groups of urls that should be grouped by a pattern. I have tried something like this bearing in mind that url_patterns will only have one row per group. The main problem here is that it seems that applying SIM…
Tag: sql
SQL Server: join data but in single row
I have a table Invoice that looks similar to this: order_id completed_at subtotal discount_amount handling_amount 100 07/01/2021 10.09 0 0 101 07/04/2021 200.30 0 0 102 07/04/2021 54.10 0 0 103 07/06/2021 12.00 0 0 And I have another table InvoiceDetail: order_id product_id qty amount 100 1234 1 1.09 100 Ship…
ActiveRecord having count query condition
I have 2 models : Conversation and Message I need to retrieve all conversations that belongs to a Brand and where there are at least one message from the brand and one message from an influencer This is my query : But i get conversations that doesn’t have messages from both… What am i doing wrong …
update join with where
I need to update a certain alert on a loan where the obligor and obligation is something, but I can’t figure out what I’m doing wrong in the join. This seems to update all alerts in the table rather than the specific one I want. We are using postgresql db Answer Workbench usually refers to MySQL. …
Data inserting in between the rows in table
I have a table which has around 1,000,000 records. I noticed that when I insert a record it does not get inserted at last instead it gets inserted in between Example My table (testing) Si. Name. Address. 1. Test. 1/2 test 2. Test. 3/4 test Si has a unique index created but no primary keys defined So when I ma…
How to generate dynamic table having begin month date and end month date Teradata or SAS SQL
I’d like to generate a dynamic Table with the start date of a month as a column and the end date of the month as another column. Ideally, I’d like to provide two years, f.e. 2016 and 2021. The output I’d like to have when providing these two years is the following: Kindly note that I require the output for…
Need help finding syntax error in SQL code [closed]
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers. Want to improve this question? Update the question so it’s on-topic for Stack Overflow. Closed 9 months ago. Improve this question I have been trying to follow along with a SQL tutorial on YT. Every …
How to create custom WEEKOFYEAR index in Snowflake?
I am trying to custom build a week index (1-52) The logic should be like: Start with the 1st Saturday of January of a year Build custom intervals from every Saturday (start of the week) to Fridays (end of the week) and increment the week index by 1. Example: Week 23 will include July 3 2021 – July 9 202…
Accurate DateDiff
I have 2 time fields in SQL. I want to calculate the difference between start time and end time in hours. From 7 AM in the morning to 7:30 PM it would be 12.5 hours but the datediff function returns 12 hours because it returns an integer. I also tried converting it to seconds: All of these return 12 hours
MySQL: Error 1045 – how to set correct rules?
I have MySQL db and need to create a new database. However, I can not do it since I keep getting the 1045 Error. shows following: I don’t even have enough rights for rewoking and granting or creating a new user. Could you please help me what to do? Answer You only have privileges on a schema named db. Y…