I’m fairly new to programming and I’m struggling with an SQL Query. I want, that the purchased articles (article_id) are grouped in an array, so they are connected to the date column. For a further process, they might be combined ( so date x is combined with articles_id [A,B,C]) To make it clearer…
Tag: sql
Generate rows from JSON (SDO_GEOMETRY)
I have a multi-part SDO_GEOMETRY that I can represent as JSON (Oracle 21c): As an experiment, I want to find a way to generate rows from the JSON: Each row is a vertex of the geometry. Question: In an SQL query, is there a way to generate rows for each of the JSON vertices? I’m aware that SDO_GEOMETRY h…
Retrieve the last valid value from a previous date
I have the following table “Rates”: aDate realRate isBusinessDay 01-04-22 1.10 1 02-04-22 1.20 1 03-04-22 1.30 1 04-04-22 1.40 0 05-04-22 1.50 0 06-04-22 1.60 1 07-04-22 1.70 1 08-04-22 1.80 1 09-04-22 1.90 1 10-04-22 2.00 0 11-04-22 2.10 0 12-04-22 2.20 0 13-04-22 2.30 0 14-04-22 2.40 1 15-04-22 …
why empty values are allowed but not null values in composite primary keys
I am working on an App connecting to the Snowflake database. I stumbled upon an issue while loading CSV files. I was using the NULL_IF condition in copy command to change column value to null if any empty value is encountered during the load On investigation, I came to know that one of the columns is part of …
Find rows with duplicate values in two columns where at least one value in one column is a specific value
So, I’m not sure how it works and I haven’t found a sufficient answer by googleing (probably not using the right buzz words). So here it comes: Let’s say I have a table like this, let’s call it persons ID Name First Name Country 1 Doe John USA 2 Doe John UK 3 Doe John Brazil 4 Meyer Ju…
Syntax error to combine left join and select
I’m getting a syntax error at Left Join. So in trying to combine the two, i used the left join and the brackets. I’m not sure where the problem is: Error: You have an error in your SQL syntax; it seems the error is around: ‘LEFT JOIN ( SELECT outbound.marketplace_name, outbound.product_tR…
Aggregate dynamic columns in SQL Server
I have a narrow table containing unique key and source data Unique_Key System 1 IT 1 ACCOUNTS 1 PAYROLL 2 IT 2 PAYROLL 3 IT 4 HR 5 PAYROLL I want to be able to pick a system as a base – in this case IT – then create a dynamic SQL query where it counts: distinct unique key in
how to get data grouped by ids
I have grouped data in a temporary table according to id_card. There are multiple activities for each card. I want to send 1 email for all activities happened on that particular card. But, I don’t know how to get data according to ids. should i use cursor for fetching the ids ? Example in the table, wan…
Query table with composite primary key, excluding specific rows
I would like to know which unique ids belong to category A but NOT category B. In the example above, only id: 2 would be a valid result I came up with this which does not work as intended: A valid approach would be to use a subquery Is it possible to do this with a single query? Answer Use
executing .py in html/php
I wrote a Python script which writes its output into a txt file. Then I included that file in my html/php website. – works good so far. Only remaining problem: I can’t execute the .py file automatically while opening the site. I know that this isn’t the best solution <?PHP exec(“pyt…