Skip to main content
Filter by
Sorted by
Tagged with
2 votes
1 answer
83 views

For each customer_id, I want to find the first delivery order. For each row of Delivery, I compare order_date with the smallest order_date of that customer_id. Why does the SELECT statement below only ...
Huy Le's user avatar
  • 1,989
0 votes
1 answer
52 views

I have gone all around the houses with this trying to use a subqueries etc but just cannot get this to work and I am thinking it should be easy. So this is what i have: SELECT DISTINCT Register....
Paula Morrison's user avatar
1 vote
1 answer
75 views

I have a table that has store names, product codes and prices. I need to pull the minimum price of a product and display a list of the product codes with their minimum price, where it all falls down ...
Jason Ronne's user avatar
-5 votes
1 answer
97 views

I want to query table2 to get results having field field_b which corresponds to the first query result's list. (More as a LIKE; the comparison won't match perfectly). I have a table with many fields, ...
Barbi's user avatar
  • 188
1 vote
3 answers
136 views

The employee table lists the employees and the history table records hire and term dates as separate rows. I need to write a query that identifies all employees from the employee table that are ...
Elliott Buchholz's user avatar
-1 votes
1 answer
58 views

I'm trying to write a query that will join a subquery with a large union query and I'm having some trouble. Below is the subquery: SELECT DISTINCT X.JOB, FOO.PART FROM (SELECT C.PART, C.ORDER_NO, C....
THard34's user avatar
-2 votes
1 answer
69 views

I work on this plugin for Wordpress to delete users with a subscriber role and 30 days since joining us; users are active or not. I cannot correct this error after activating. if ( !defined('ABSPATH') ...
Edward's user avatar
  • 11
-3 votes
1 answer
59 views

I am trying to copy a few fields of video information from one MariaDB table to another using a subquery, decoupling some video info from a classified ads table for later refactoring. video: id (int ...
Palm Boom's user avatar
0 votes
1 answer
73 views

I am trying to come up with T-SQL query to delete data based on these conditions: Find data that have same Email. If that user has both AllLocations 'Yes' or 'No', delete entry/entries that are not ...
Java's user avatar
  • 1,334
-2 votes
1 answer
67 views

I'm trying to retrieve employees who earn more than the department's average salary using a subquery in PostgreSQL. SELECT employee_id, first_name, salary FROM employees e WHERE e....
Wesley Stephens's user avatar
1 vote
0 answers
104 views

In Snowflake I'm trying to de-identify data stored in a JSON column based on configurations in a separate table. I created a custom SQL function DEIDENTIFY_JSON which uses a subquery to look up the de-...
Lonely Planeteer's user avatar
-1 votes
2 answers
87 views

My app has a function that deletes a specific row in a SQLite table based on the row index or position, but the table doesn't have a column that stores a row index for easy access. My app retrieves ...
ThN's user avatar
  • 3,294
-1 votes
1 answer
57 views

so I'm trying to using left join instead using not exist (which I always disliked), but somehow I'm not getting the same result. Original query that returns the correct result: select o.number, o....
Yuan's user avatar
  • 13
-2 votes
4 answers
145 views

I have a table that stores customer transaction data. I want to select all customers that have purchased item 1 (64244), but remove/ignore them from the results once they've purchased item 2 (64270). ...
Nic's user avatar
  • 23
0 votes
1 answer
74 views

I have two tables Table 1 ID Parent ID 00001256 00001298 00001256 00087612 00098542 00009214 00087612 00087343 00098542 00456336 Table 2 ID Flag 00001256 TRUE 10000000 00087612 TRUE 10000001 10000002 ...
Nerdio's user avatar
  • 1
-2 votes
2 answers
113 views

I have the following query that is not returning the result that I need, which is the top contact from each organisation, but what I am getting is the top contact repeated for each row, not for each ...
Chris Lane's user avatar
0 votes
2 answers
140 views

It is Bigquery and below are the sample tables and contents dde-demo-d001.sap_crm.transactions_bkup case_guid transaction_header_guid 005056935CD81EEF92DF522476D53CAB 00505693-5CD8-1EEF-92DF-...
Jaango Jayaraj's user avatar
-3 votes
1 answer
57 views

I have to write an INSERT query in sqlite3 that uses the values of multiple columns from the same nested query. In the example below i need to insert into table_a multiple values from the same nested ...
BestCrazyNoob's user avatar
0 votes
1 answer
62 views

I have following SQL query, for which I want to write a CriteriaQuery select * from EntityA ea where ea.lastUpdateTS >= (select creationDate from EntityB where status='PUBLISHED' order by ...
swapnil's user avatar
  • 35
0 votes
1 answer
100 views

I have to find a price by choosing the correct price out 3 options in a hierarchy from highest to lowest if "tran_type" is Quot than choose this price over all from the [price] column and ...
Siege's user avatar
  • 19
0 votes
0 answers
32 views

I’m encountering an issue in MS Access with a subquery that works perfectly as a standalone query. Here’s the standalone query: SELECT [**Site_Conf_Details].*, IIf([Sharing] = -1, "Yes", ...
Ildefonso Baena's user avatar
-2 votes
2 answers
261 views

I am trying to select the maximum ImportDate for each person. For this person "Bob James" he should have the last 2 rows selected with ID 267311 and 267342. I need to see every column in the ...
Austin 's user avatar
0 votes
1 answer
65 views

Am I able to use this subquery to solve this SQL problem without having to use GROUP BY? For each continent show the continent and number of countries with populations of at least 10 million. world(...
obito uchia's user avatar
0 votes
2 answers
93 views

I'm trying to return how many 'males' or 'females' are counted in each specific event for the products brand name column. I tried to use subqueries and use the same syntax for both genders. Since I ...
paulo sampieri's user avatar
0 votes
1 answer
96 views

Looking to be able to pull a code with a separate query if it's missing from that customers list but still in the WHERE IN clause. So for this the query I have only works on items that are present in ...
Siege's user avatar
  • 19
1 vote
1 answer
70 views

So I am new to Postgresl and am trying to get familiar with nested queries and how they work as there seems to be some conditions that add to what intuition seems to tell me. I learned, at least I ...
user658459's user avatar
0 votes
2 answers
52 views

I have tables A, B, C, and D. They all have the following fields: Division, Vendor, Deal, Reference, and Amount. I want my final table to contain Division, Vendor, Deal, Reference, and 4 separate ...
Justus's user avatar
  • 1
0 votes
3 answers
115 views

I need to find all the users who have a MAX Process date. There are often multiple records for the same person but different process dates. PROCESS_DATE | SSN | Amount | CODE | SOURCE | ...
Mani's user avatar
  • 43
1 vote
1 answer
105 views

I am trying to query the correct price by going through and choosing between 2 prices. These are in order of importance from highest to lowest: if [tran_type] is equal to Quot than choose this price ...
Siege's user avatar
  • 19
-1 votes
1 answer
98 views

Does SQLite support ALL and ANY keywords? I keep facing syntax error while using them. SELECT name, price FROM products WHERE price > ALL ( SELECT price FROM products WHERE category = '...
daniial's user avatar
0 votes
2 answers
60 views

I have two queries that run fine on their own and I need to combine them. One query uses "Group By" and the other query uses a subquery. First Query: SELECT LH.AISLE AS "Aisle",...
Inigo CA's user avatar
0 votes
1 answer
28 views

Working with a patient visits during a trial. THey're scheduled to come in at specific instances, visit ID- Safety Visit Cycle 01 Day01... cycle 2 day 01.. and so on. I also have a study group ...
Hwa Fine Han's user avatar
-3 votes
2 answers
70 views

Scenario Requirement. select all rules that are inactive (Rule_table.Status) matching the most recent audit record with audit_text='status_change' where its created date has passed 6 months. In the ...
sabu's user avatar
  • 91
0 votes
1 answer
75 views

I have a table which contains a data field of assorted IDs written in plain text. Other_ID Data Date 123 user_id:098; metdata:[ID: 6482] 2024-10-13 456 user_id:754; metdata:[ID: 0743] 2024-10-12 123 ...
noone's user avatar
  • 1
1 vote
1 answer
117 views

Currently using PostgreSQL 16.4. I looked at this post but it didn't cover my use case. I would like to conditionally update two (or more) columns with the same condition, so I don't have to rewrite ...
Jeff's user avatar
  • 602
-1 votes
1 answer
45 views

Good afternoon, I have two tables (call them table a and b), the first has one row per id, with a number attributed too it as follows: | ID | Number | | 1 | 10 | | 2 | 21 | | 3 | ...
Ajk89's user avatar
  • 21
0 votes
1 answer
51 views

I am very rusty on MySQL and having trouble updating columns based on a different column in a different record. I'm thinking I need to do a sub-query. The table being queried is an aggregate of other ...
user6631314's user avatar
  • 2,050
0 votes
2 answers
157 views

I have 3 tables: products, product_options and product_option_choices. Products can have multiple options, options can have multiple choices. Choices can adjust the main product price (...
twistedpixel's user avatar
  • 1,225
0 votes
1 answer
77 views

my base data: Process ID Location Date Timeliness 2030608 New York May 24 in time 2067393 Ohio May 24 overdue 1329306 Ohio May 24 in time 1740814 Ohio June 24 overdue 1924676 Chicago May 24 overdue ...
atwerq's user avatar
  • 3
1 vote
1 answer
73 views

Here are two sql : the first uses join method to execute the second one uses dependent subquery to execute IN the slow log ,we can see the examined rows and query time. When the tow methos have the ...
Luodan's user avatar
  • 11
-1 votes
1 answer
68 views

Table tblStudents columns: id, name, gender, SchoolName, SchoolId. Table tblSchool columns: id, name, location. select name, (select name from tblStudents as a where a.SchoolId=id ...
Deepankar Joshi's user avatar
-4 votes
2 answers
119 views

I select data from temporary table: CREATE TEMPORARY TABLE IF NOT EXISTS "tmp" ( "fuel_type" TEXT, "litres" NUMERIC(8,2), "is_rent" BOOLEAN ); ...
Ascerd's user avatar
  • 1
-4 votes
1 answer
81 views

How can I create a subquery that uses the value of an outer column for a subquery which uses a case expression? SQL Example: SELECT name, average, crnt, goodFactor FROM ( "Crispy ...
stackoverflow's user avatar
0 votes
3 answers
125 views

Service table: Car_id Service Date 101 2016-02-05 102 2017-02-06 103 2017-05-07 104 2017-02-08 105 2017-05-09 106 2016-03-10 101 2016-08-10 101 2016-02-20 106 2016-08-15 106 2016-12-20 Expected result:...
user234568's user avatar
0 votes
1 answer
129 views

I am working on a SQL query in SAP Business One, and I keep encountering the following error: Table must be specified for selection. The query I am using is as follows: SELECT o."DocNum&...
Quaeck's user avatar
  • 11
0 votes
0 answers
44 views

I have some problems getting a query with the following: I want to select the records whose date is less than or equal to a date given by parameters but I also have to take into account that the ...
junagel's user avatar
  • 21
-1 votes
2 answers
94 views

I have two SQL queries like this for postgresql: The first query is fetching subscriptions that were never synced or that were updated recently and synced a long time ago: SELECT * FROM subscriptions ...
Valentin Nasraty's user avatar
-1 votes
1 answer
42 views

I have table a where I have Transaction_id (not unique, for one transaction it could be many string value for other status), status (for example A001,A002,A003), string value. I want to join to my ...
lsk123's user avatar
  • 21
0 votes
0 answers
31 views

How to get records for one customer that exist in two tables but in one of them there are more records. For example in the fist table there are 3 records with different amounts and in the second there ...
nikola796's user avatar
1 vote
1 answer
2k views

I want check whether the particular email template is used in any other model instance and model Rule we have action(JSONB) while running query below query i'm getting error I had added the sample ...
Tariq Jamal A's user avatar

1
2 3 4 5
230