Skip to main content
Filter by
Sorted by
Tagged with
0 votes
2 answers
121 views

I have a table t containing minute-level data with fields such as datetime (timestamp), stock_id (stock code), and ret (return). My goal is to: First, group by date(datetime) and stock_id, and ...
haru's user avatar
  • 11
0 votes
2 answers
123 views

I have a table of customer data. I will be joining it to a location table. Customer ID is distinct but Location ID is not because multiple customers can belong to one location. Each customer is ...
HawaiianShirts's user avatar
0 votes
2 answers
100 views

This is my sample data set in a table called "status": fiddle create table status(id, status)as values (1, 'in') ,(1, 'out') ,(1, 'in') ,(1, 'in') ,(2, 'in') ,(2, 'in') ,(...
rickyProgrammer's user avatar
0 votes
3 answers
73 views

I'm trying to count a book in the database where that belong to different locations. For example the book "Interview with the Vampire" by Anne Rice exist in both library code of 40 and 30 (...
Yuan's user avatar
  • 15
2 votes
5 answers
106 views

I have the following Postgres SQL tables: db<>fiddle create table t1(id,sval)as values (88, 'X129de') ,(4, 'YHK33e') ,(44, '1K4892') ,(53, 'YHK33e') ,(42, 'YHK33e') ,(...
kahhengchong's user avatar
0 votes
3 answers
142 views

I have this query SELECT a.Campaign, COUNT(DISTINCT a.Customer) AS 'Records', MIN(a.LastRecord) AS 'First Record', MAX(a.LastRecord) AS 'Last Record', MAX(a.daytime) AS 'Records up ...
Kaptah's user avatar
  • 9,887
2 votes
1 answer
110 views

If "HAVING" is more versatile than "WHERE" in SQL then why bother with it? SELECT AVG(salary) AS avg_salary FROM employees WHERE salary > 50000; SELECT salary FROM employees ...
Epic Wolf's user avatar
-1 votes
3 answers
167 views

In SAS i write a code that in the log looks like: 2 proc sql; 3 create table test as 4 select 5 ID, 6 GENDER, 7 BIRTHYEAR 8 from 9 libname.dataset 10 group by ID 11 having ...
user2836445's user avatar
3 votes
3 answers
87 views

My dataset looks like this: TEAM_ID PLAYER_ID NUM_POINTS 21 39 20 21 50 10 21 67 10 22 74 0 22 73 0 I want ...
ellen's user avatar
  • 714
-2 votes
1 answer
74 views

I'm working with the Kaggle dataset of Fitbit used for a Google data analysis certificate project, and I'm trying to find how many days with 0 steps every user (id) has. demo at db<>fiddle ...
Hazael Diaz Bernal's user avatar
0 votes
1 answer
74 views

Consider the following relational schema: candidates (candidate_id, skill) [Sample input table] Select candidate_id from candidates group by candidate_id having sum(if(lower(skill)='python' or lower(...
Suhail's user avatar
  • 1
0 votes
1 answer
60 views

I had an elasticsearch with version 6, now I need to find duplicate documents in a index "es_index" by field "userName" with same field value. That means I need to write query like ...
Joshua's user avatar
  • 125
1 vote
1 answer
73 views

I'm trying to select query from row count double based on ID and DATE in MS Access. I want to keep it as a single query. What are the possibilities of this being applied? Or another method? Please ...
dlaksmi's user avatar
  • 213
-2 votes
3 answers
120 views

I know this will not work but can someone explain why? SELECT * FROM employees HAVING salary = MAX(salary); The code does not work with WHERE clause because it's filtering against an aggregate ...
salim's user avatar
  • 3
-3 votes
1 answer
58 views

enter image description here I wanted to get 1,3,4 back as their tiv_2015 values are appearing more than once, but I got 1 only. Help in need to understand how select works after having clause. select ...
yang song's user avatar
0 votes
1 answer
67 views

The below code (Databricks SQL) produces the table following it. I am trying to adjust this code so that the output only includes zip5 records that have only 1 (or less) of each facility_type ...
Dr.Data's user avatar
  • 191
1 vote
2 answers
155 views

I am having an issue filtering a Mariadb query through HAVING on a computed column based on a Mariadb variable. I am having an issue in Laravel Elquent where a query I am running is producing no ...
James Poel's user avatar
0 votes
0 answers
40 views

I have tables users: (id, name) scores: (id, user_id, value, created_at) How can I calculate rank of user by sum of value, but if sum for some users the same upper should be user with highies last ...
Stanislau Karaliou's user avatar
-1 votes
2 answers
101 views

I'm trying to write an SQL query that displays customers' names who have a total purchase greater than the average purchase of all purchases. I tried using the code below, but it gives an error. ...
Sebastian Llaurador's user avatar
-1 votes
2 answers
1k views

I have a table customer_purchases with 3 columns: customer_id, product_id, quantity, where each customer_id can buy multiple products having different quantities. I need to find customers whose ...
Dharminder Singh's user avatar
0 votes
2 answers
65 views

I am trying to isolate those records of [table] which only have specific (let's say bad) attributes. Bad attributes are those with ids 3, 6 and/or 7. To do that, I came up with the following solution: ...
Ma0's user avatar
  • 15.2k
0 votes
0 answers
26 views

In a database that I'm creating, I need to match parent contact information with kids that are given to me in a list format. I'm matching student ID numbers with parent emails as primary keys and ...
Giraffeknees's user avatar
0 votes
1 answer
73 views

So currently my query shows result of all the "preferred" travel destinations of countries based on the continent, and I'm adding a having clause to show the continents that have more than 1 ...
Yuan's user avatar
  • 15
-5 votes
1 answer
96 views

How does this work in SQL sum(o.product_name='Bread') > 0, e.g if the orders table (o) has product_name column such that the entry is Bread then will the condition o.product_name='Bread' return 1 ...
user1864024's user avatar
0 votes
2 answers
65 views

I have 3 tables : accounts, contacts, contact_activity. Accounts can have multiple contacts, also multiple activities whereas contacts can also have multiple activities. adding tables queries below: ...
Gurdeep Singh's user avatar
0 votes
0 answers
90 views

Here is the link for the problem: Hackerrannk-challenges One of the solution: SELECT c.hacker_id, h.name, COUNT(c.challenge_id) AS cnt FROM Hackers AS h JOIN Challenges AS c ON h....
khatia's user avatar
  • 9
-2 votes
2 answers
46 views

can anyone tell me, why is this query giving an error Write a query to find the maximum total earnings (earnings) for all employees as well as the total number of employees (num_employees) who have ...
Achint Kaur's user avatar
1 vote
2 answers
86 views

How to count the records of each remark? Each remark has a different number inside the remark column value. I need to group the records based on Remark content but not with cid###. need to group by ...
dotnetdev1's user avatar
0 votes
1 answer
352 views

[![enter image description here][1]][1]now say I have a database, where there is a table kits_parts_needed, and I need to figure out what kit I have parts for, there are fields in this table that ...
Collin Short's user avatar
0 votes
0 answers
80 views

The task was - https://platform.stratascratch.com/coding/514-marketing-campaign-success-advanced/official-solution?code_type=1 And I'm a little bit confused in the code. SELECT user_id FROM ...
Ruslan Efanov's user avatar
0 votes
3 answers
97 views

I made a delete query to delete all records in tbljournaalposten where the field volgr occurs more than once. delete from tbljournaalposten where tbljournaalposten.ID in( SELECT ...
Johan's user avatar
  • 21
-2 votes
2 answers
74 views

This is my table: enter image description here I have a problem I don't understand the difference between the following two queries: Query #1: SELECT productID, SUM(soldQty) FROM Sales ...
Adele's user avatar
  • 1
0 votes
1 answer
47 views

So this my query below: select creditcard from user where preferred_card = '1' and uder_identification_code = 'creditcard' group by creditcard having count (1) > 1; So I'm trying to get list of ...
Yuan's user avatar
  • 15
0 votes
1 answer
20 views

I am having an issue joining these two tables. The query below will return ID-A 1 and 8. However, I also want to check if ID-A has StatusCode= 2 in TableA. How do I join the two tables that return ...
Allen King's user avatar
  • 2,532
0 votes
1 answer
54 views

I know this has been answered, but I can't decipher the solution from the responses given my lack of experience with mysql, so forgive me for asking the same question again. I am converting ms-access ...
JDubs's user avatar
  • 21
0 votes
2 answers
642 views

Trying to select earliest order_date for each customer_id. Using following query SELECT customer_id, order_date FROM Delivery GROUP BY customer_id HAVING MIN(order_date) = order_date But ...
BenS's user avatar
  • 23
0 votes
1 answer
45 views

I have a MySQL table containing users, files and file ages as shown below. Users Files File age A 1 42 A 2 17 A 3 4 B 4 85 B 5 73 B 6 11 C 7 6 C 8 9 C 9 3 Now I need to select the names of all files ...
Ben's user avatar
  • 12
1 vote
1 answer
96 views

I am querying our IT service management system and want to bring back tickets that match the following criteria. Must be an incident Must be in an open state The user who logged it must have another ...
Andy P James's user avatar
-1 votes
1 answer
63 views

How the HAVING clause works in SQLite? My code works and returns the name and division of the highest paid person in each division. However, the use of the HAVING clause does not make sense to me ...
Srihari P's user avatar
0 votes
1 answer
59 views

I have two tables - input: Input_table ait_no schema_nm column_nm table_nm 1 aic ssn sic_tabl 2 aic ssn_1 bhue_tab 1 aits ssn_no eyfu_tab 1 aits ssn_number gic_tab 2 aic is_snn_no yfjs_tab 2 aic ...
lemon chow's user avatar
0 votes
1 answer
42 views

I'm looking to write a SQL statement but having trouble. Let's say I have a table with the following data: id ip 1 1 1 1 1 1 2 1 2 1 3 2 3 2 4 2 4 2 4 2 5 3 5 3 6 4 6 4 7 4 7 4 I want the results of ...
Marc A's user avatar
  • 1
1 vote
1 answer
55 views

After a lot of try, I am not able to translate this kind of sql queries into django filtering. Basically, it is retrieving all users with at least x selected tags (and other filters). In the case of ...
Guillaume Cisco's user avatar
1 vote
1 answer
215 views

I've got these 2 tables, content item and a join table to categories. I simply need a query to select items that are in multiple categories (in ALL categories, not in any category). -- content items ...
scms's user avatar
  • 93
0 votes
1 answer
57 views

I have an ecommerce database that contains an 'Order' table (tblOrders). In this table there are individual orders with OrderTotal, Name, Email, etc. If the user checks out as 'guest', a CustID of 0 ...
hanji's user avatar
  • 357
-2 votes
1 answer
42 views

I have table, like: Id Account Date Amount 1. ad@ind 07.11.2022 354 2. ad@ind 10.11.2022 586 I need to find record, where is maximum number of month and get amount in this date. How is it to do? Max(...
danilchik22's user avatar
1 vote
0 answers
100 views

I'm trying to use the HAVING funtion in a SPARQL query. While the query works fine in Protege, it does not return any result when I use it in a query in the rdflib package(it does not raise an error ...
Samah K's user avatar
  • 23
1 vote
1 answer
3k views

Show unique first names from the patients table which only occurs once in the list. For example, if two or more people are named 'John' in the first_name column then don't include their name in the ...
Akshat sharma's user avatar
1 vote
1 answer
40 views

I try to find the duplicates but at the same time be able to see it in a different columns but this duplicates is in the same report and also I verified the duplicates by year. report id_tip date ...
Al.Vioky's user avatar
-1 votes
2 answers
49 views

MySQL / MariaDB structure: Person | id | |----| | 1 | | 2 | | 3 | Car | person_id | car | |-----------|-------| | 1 | Ford | | 2 | Mazda | | 3 | Ford | | 3 | ...
Liran's user avatar
  • 283
0 votes
0 answers
65 views

Why does the number of records increase when adding a 'country_id' constraint? My first request. 30 entries are displayed here : SELECT app_id, sum(installs) FROM application.app ...
danilchik22's user avatar

1
2 3 4 5
34