In table_A I have data from this week, the IDs started from 1 up to 5000. In table_B I have data from last month, whereas the first let’s say 3000 IDs conflict with the ones in table_A, and it’s not the same data for all of the IDs (ID 1 in table_A is not the same as ID 1 in
Tag: sql
SQL SELECT “pair” records
There are cities, suppliers, and customers tables. Each supplier, (as well as customer), is located in one and only one city. How could I select pairs of supplier and customer within the city, where each of them is mentioned only once? P.S. if there is no “pair” NULL should be instead. E.g.: cityI…
is it possible to do a conditional concat?
I have a query that pulls different data but for one field it concats its since the URL is partially filled in my db but the problem is if logourl is blank then I just get https://my_url.com instead of the full URL. This is having down stream impact. Is there a way to only concat if logurl is not null?
SQL Query between a date range and a time range in MariaDB
I’m having trouble writing this query to give me any results. I’m using MariaDB as well. The DATE_ADD clause works just fine and gives results within that interval, but as soon as I add in the TIME function nothing is returned in the results. The CallDate format is 2021-09-21 HH:MM:SS I have tried…
How to create new count column based on adjacent combinations in existing table
I have a simple table I’ve already built in BigQuery and all I want to do is what feels like a simple count of the number of times the combination of the person_id and the specific activity in the activity column has appeared in that table and create as a new column with a value/count of the adjacent co…
Raw query results multiplies many times when I use INNER JOIN in Django
I can’t figure it out why my raw query multiplies the result as many time as the number of users. I’m using INNER JOIN and I bonded two objects so I really can’t get it. (I’m not experienced in Django Query Language so I’m using raw query). views.py If I’m using Django ORM …
Write columns as rows (PostgreSQL)
I have a table: campaign_id media installs content_view date unique_purchase 7564 google 613 45 2021-09-01 1 7564 facebook 21 33 2021-09-02 2 3451 google 83 12 2021-09-01 0 I want to create view: write installs column values as metric_key=installs, metric_name=installs, metric_value=… write content_view…
Insert price to the pivot table
I am trying to insert data to a pivot table order_serrvice using arrays I follow this code: https://blog.quickadminpanel.com/master-detail-form-in-laravel-jquery-create-order-with-products/ the column qty and service was inserted properly but the price does not, I dont know why? order_service table: OrderCont…
How to use Oracle XMLTable to retrieve the value/condition inside a tag?
I have a SQL using XMLTable to retrieve tag values such as Tag>Value</Tag which works fine. But what about value/condition inside the tag? See following XML with tag T2 having a remove condition = true. How can I retrieve that condition using XMLTable? Answer Pretty much the same way, just use the XPath…
Exclude records where particular value exists in related record
The below dataset displays the audit trail of a “review” record that has gone through a number of statuses. What I’m trying to achieve is only display the case ids where the auditcasesubstatusname is one of (‘Checklist Complete’, ‘All Documents Available’, ‘Revi…