I’m trying to achieve the output table using the input table. The input table contains id and name where id has the numerical values and name contains JSON value. I can get the output by writing a …
Can we concat as well as replace string values in SQL Server (SSMS)?
I executed below query, but I got result as null values. Instead I want my output to be: Answer The more recent versions of SQL Server support concat_ws(): In older versions, you can use:
How to get first character-set of string in sql?
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…
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…
Combining individual select aggregate queries into a single query
I’m trying to optimise some SQL queries in a script of mine that uses a SQLite database. Currently I loop through creating multiple queries as below to get aggregate data for a list of IP addresses. …
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 can I merge my 3 queries into one query that returns all
The first query gets the date of a football match for the given week, the second query gets the name of the home team for each match of the week and the third query the away team. How can I structure …