Skip to content

Tag: sql

SQL query for customer and order- profit data

I am trying to write a query. I have 2 table in first table customer and 2018, 2019 order and profit data. In second table customer and 2020 0rder and profit data. I want to write a query that will return all customer and their order and profit in a different format. I have attached the screenshot of data and

GROUP BY Subquery returns more than one row

I’m looking for a way to solve the following situation. I have a table that I need to return only one number for each “p.pays”, This query is supposed to list “nom from table Pays” where at least half of the “athlete” have are in the table “Resultat” but m…

merging tables with different structures

I have two tables where I want to find the outer join based on a Ticker variable. In Table I, I have only one Ticker for each entity (fund), but in table II, I may have multiple records (multiple Ticker) for each “FundID”. The goal is to count the unique funds. I want to have table III, which is t…

SQL Query: Aggregate multiple values with Case and count it

I have the following query and I want the output to show only the count of Active Members and Non-Active Members: The result I am getting is this: Where the two lines “Non Active” are of this 2 status (‘Unemployed’, ‘Housewife/Student’), I’would like to know how aggre…

How can I join two results

I have 3 tables purchase, air_transfers and sea_transfers. I have made the example code in db fiddle. My problem is on 6th paragraph where I don’t have any sea transfers, I get null as id and thats because I’m using id from sea transfers. What should I do to fix this? purchase table: air transfer …

SQL : String extraction from Path

Could you please help on how can I extract String1 , String 2 and String 3 to use these in my SQL queries .. Answer Please try the following solution. It is based on tokenization via XML/XQuery. After that it is very easy to pick up any token based on its position. SQL Output