I want to get 202500 and 37500 without not adding removed characters (in eg: 7, 5). (ie. first string gp in columns).sample-image description here But, I don’t know to get string in front of blank string “”. I have a little exp in sql. pls show me ans. Answer Use SUBSTRING_INDEX instead | Ex…
Tag: sql
Oracle SQL: how to concatenate text until reaches maximum size
I have a case: some script to reproduce: And Select: What i want to achieve is concatenate texts until sum of them is less than 3000. If larger, then another text. And here goes problem: texts with group 1 when You sum them is greater than 3000. Text with id = 2 supposed to have group 2 but is 1.
How to query Json field so the keys are the column names and the values are the column fields
PostgreSQL database name is contacts_contact and the column I’m interested in is called “fields” ‘fields’ column looks like this in my database: And a second record: The ‘fields’ column has fields that look like the two JSON data I shared. It is pretty much responses …
How to evaluate a logical expression in a column in SQL
let’s say I have a database table “ACCOUNTS” where it only has 3 fields: ACCOUNT_NUMBER (BIGINT) CREDIT (BIGINT) DEBIT (BIGINT) And I simply want to make a query that will show only two columns: ACCOUNT_NUMBER (BIGINT) “BALANCED” (A boolean value. True if Credit == Debit, false o…
How to select only entries that didn’t repeat before a specific date?
My issue is that I’m stuck on making a select query where I need to select only items from latest 24 hours, that don’t repeat themselves on entries before those 24 hours. Here is a table: name date Mark 2021-05-27 Jake 2021-05-27 Anthony 2021-05-27 Anthony 2021-05-26 Expected output: name Mark Jak…
How to automate parameters passed into pandas.read_sql?
I am trying to create a methodology for passing parameters automatically through something like locals(), similarly to how f-strings work. How it currently works However, this approach means I cannot copy-paste the SQL into SQL developer or similar, and run it from there. So I would like an approach that make…
How would i restrict the company table to only allow each companyID to 10 countries?
This is my answer at this point, if this is correct can someone give a more in depth explanation as I am trying to teach myself SQL/ or point out how wrong I am kind regards, new SQL user. PS. I understand i can use a check constraint or a check trigger but I am trying to do this in
Search using LIKE operator with multiple dynamic values accepting both full and partial text match
Is there any way to do multiple term search in a column using like operator dynamically in SQL Server? Like below For example: input values “goog; micro; amazon;” (input value should auto split by delimiter ‘;’ and check the text exist in the table) means that Search term ‘goog&#…
Apply SUM( where date between date1 and date2)
My table is currently looking like this: I’m trying to sum values of ‘ON_Prepaid’ over the course of 7 days, let’s say from ‘2020-01-01’ to ‘2020-01-07’. Here is what I’ve tried Things should be fine if the dates are continuous; however, there are some mis…
Is there any way to join two queries without common columns
Could anyone help me to join two tables without common columns? I have two tables: Tab1 Column1 Column2 K1 a K2 b Tab2 Column1 Column2 K3 c K4 d K5 e The result of select should be: Table1.Column1 Table2.Column1 K1 K3 K1 K4 K1 K5 K2 K3 K2 K4 K2 K5 How do I do that? Answer Fiddle -> https://www.db-fiddle.co…