Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [query]

Writing queries to request or change information stored in a database or other information management system. Questions should include table and index definitions, sample data, expected output, and a tag for the specific system (e.g. MySQL, PostgreSQL, Oracle, SQL Server, MongoDB).

0
votes
1answer
31 views

Employee Shift Check - Nested Cursor

I have a query that returns the availability of an employee (only days they are available): SELECT emp_id, emp_number, area, day_date, shift_type, start_time, ...
0
votes
0answers
16 views

how to do this query [on hold]

I have two tables in access, one shows the worker details, and the other shows the worker shifts, I want to create a query that shows me in the specific day how are the available worker workers, which ...
0
votes
1answer
21 views

need help in the update query

table name:- **t_ci** s39 column_name 176 i want to have my table like this s39 column_name 176 176 But this query works UPDATE t_ci SET s39=s345 WHERE blueprint_id=1234; But I ...
-2
votes
0answers
59 views

3 question about database. i hope any one help me. i will be so gratefuel [on hold]

hello i hope everyone is fine. may i ask for help please? i am beginner in the programming filed. i try to build my own app and i got confused in the database so i hope anyone helps me i will be so ...
0
votes
2answers
20 views

Complex JSON query

I have a table like that: id | lat | lon | date | speed 1 | 45 | 66 | 2018-02-01 | 139 1 | 44 | 63 | 2018-04-01 | 129 2 | 41 | 56 | 2018-01-01 | 109 2 | 44 | 45 | 2018-04-01 | 99 I ...
0
votes
1answer
49 views

Query with CASE expressions on a Logger Devices database

select t.DATETIME, max(t.Depth) Depth, max(t.Temperature) Temperature from( SELECT CAST(readingDTTM AS DATETIME) DATETIME, case Sensor when 'Depth' then lValue end ...
0
votes
2answers
45 views

Using EXCEPT with NOT EXISTS [closed]

SELECT DISTINCT cname FROM account AS cust_account WHERE NOT EXISTS ( SELECT type FROM account EXCEPT SELECT type FROM ...
2
votes
1answer
36 views

How can I optimize this MYSQL Script For many Records?

I have This script by Helping @lukstorms , -- DROP TABLE IF EXISTS test_words; CREATE TABLE IF NOT EXISTS test_words ( id int unsigned NOT NULL PRIMARY KEY, words text NOT NULL ); -- DROP TABLE ...
0
votes
2answers
45 views

SQL date and time query not importing all

I have the below table and when i run this query: SELECT * FROM table1 WHERE Date <= "11/15/2018 12:00:00 AM" it only retrieves the dates 15,14,13,12,11,10 and 1 of Nov 2018 . How can i solve ...
0
votes
0answers
31 views

Collect data checklist from different table

I want to collect data checklist from 5 different table. in example table c have data with same foreign key "id_name" then its state "yes" else "no". This is my sql statement select a.id_name case ...
0
votes
1answer
24 views

SQL query - Do I need a full join to produce this combined result?

With two tables structured like this: Table1 Table2 ---------------- ---------------- id, time, x id, time, y, z 1 1 1 1 2 ...
0
votes
2answers
21 views

postgres simple number to string mapping

I have a an Enum at the programming language level which is stored as a simple integer on the table. Think: APPLE = 1 GOOGLE = 2 MSFT = 3 AMAZON = 4 ... (100s more) I just wanna query the table and ...
0
votes
2answers
89 views

Sql Query Performance

I have one query for the report. Query Use RIS select CİHAZ,sum(sayi) as [Çekim Sayısı], count(*) as [Hasta Sayısı] from (select CİHAZ,[KABUL NO],[TC NO], count(*) as Sayi from (SELECT a....
-1
votes
0answers
12 views

Group by getting correspondent next column

I'm facing an issue which I cannot solve and would require some assistance. Having a table as follows: date ts isactive val description "31-Dec" "2018-12-31"...
0
votes
0answers
21 views

Excel query execution status

I have inherited this huge Excel file that has a connection to the database and it will retrieve data on opening. This file is huge and it takes a long time to update (hours) and I'd like to know ...
1
vote
1answer
14 views

Get parent/child or parent/siblings depending on the ID passed

This is similar to my table: | id | parent_id | title | |----|-----------|--------------| | 61 | NULL | title of 61 | | 62 | 61 | another title| | 68 | 61 | more text | |...
0
votes
2answers
28 views

query to replace text with sequential numbers

I have an images database, the default sort is the "name" column, and the "description" column content is the exact same in all files in the table. what I need is to replace certain text in the "...
0
votes
1answer
44 views

mongodb array query woes

I am struggling with array matching and getting multiple records back. "players" : [ { "pname" : "player_4", "loc" : [ -2.2, 1, 0] }, { "pname" : "player_2", ...
0
votes
0answers
19 views

Oracle Best-Buyer-Customer is Wholesale or Retail buyer

I have data warehouse with Fact table Orders, and CustomerDimension, and TimeDimention, and BookDimension. CREATE TABLE DIM_CUSTOMER( DIMCUSTID NUMBER(6) PRIMARY KEY, CustId NUMBER(4) ...
0
votes
0answers
29 views

Confused mysql index priority

Situation I have the following query that finds 3 candidates whose total point are larger than a random number. SELECT * FROM ( ...
0
votes
1answer
25 views

When I try to update/set a datetime I get an invalid mysql syntax 1064

I copy a value from the pre-existing values. I update the date. I do an update query. It has an issue and the issue seems to be the time. Here's my query: UPDATE xxxxx_eb_events Set ...
0
votes
1answer
40 views

Query to get all schemas in a database in PostgreSQL?

I'm not looking for the command \dn of psql, but instead of a query in SQL language that selects all schemas in a given database.
0
votes
2answers
48 views

How to get the nearest date to a record date in sql?

I have the following data structure: Table A: ID | RequestNumber | Date ----+-----------------+----------- 1 | 1 |2017/09/27 2 | 1 |2018/06/02 Table B: ...
1
vote
1answer
44 views

Fact table for sales product - oracle

I have sales fact table (which has quantity - price measures) and dimensions (product - customer -time) my table schema: I need a query to get best selling product; then show list of amount paid for ...
3
votes
0answers
41 views

Query for getting reserved seats in a cinema

I have this cinema project for a course. And I have to visually show the seats to user so they can reserve their preferred seats. I need to get the reserved seats from the database of that particular ...
0
votes
2answers
59 views

Which column to index for this query?

select DISTINCT id_request,username_request from darkhast_follower where darkhast_follower.id_request != '9762952594' AND darkhast_follower.id_request != 'null' AND darkhast_follower.status !=1 ...
2
votes
1answer
88 views

Why can vectorization reduce the use of virtual functions?

Vectorized Query can be very helpful to get a high-performance analytical systems. I know that vectorization can execute all operations on blocks of values (SIMD instructions) instead of interpreting ...
0
votes
1answer
20 views

Postgresql filtering by value over rolling time period

I am newbie to postgresql and still getting my head around. I have used windows function etc. till date and yes I can make some sense. I have got the following data set: I need to find those ...
2
votes
1answer
37 views

find 16,000 words and replace with ##

I need to do a find a replace but rather than find one word to replace with another I have about 16k words, so as an example; table 1 has two words apple,orange - table 2 has the contents of a book, i ...
2
votes
1answer
63 views

Best way to compare multiple non null/non zero fields in a row in T-SQL?

I need to compare figures across a row and show where there is any mismatch, excluding zero and null values. So in the example, ids 1, 4 and 5 would be returned. What is the most painless way of doing ...
-1
votes
2answers
81 views

DB2 Join with case when statement or union [closed]

How can I use a case statement in a join? Given: 3 Tables Dealer DEALER_NO CUST_ID 001 100 002 200 003 300 Table: Customer CUSTOMER_NO NAME CUSTOMER_MAIL 100 JOHN ...
1
vote
2answers
53 views

How can I add “in” keyword in this code to accept more than one value in gender and age parameters using SQL Server 2012

I want the parameters in Age and Gender to accept more than one value Create Procedure [Admission].[SelectPlayerData] @MembershipNumber varchar(20), @PlayerName varchar(70), @PlayerNameEnglish ...
3
votes
1answer
80 views

Finding gaps on intersection dates

This is a problem I've been trying to work through on and off for the past month, and haven't made any progress. Essentially, I am working with a HR system that stores two major types of position for ...
0
votes
4answers
51 views

Subtract from two MYSQL Queries

How can I subtract query result B from query result A so that I can see the difference between the two? A: SELECT character_name, ROUND(minutes_played / 60, 0) FROM outfit_member WHERE ...
1
vote
1answer
32 views

Query Efficiency - Filter people when name and surname are different columns, and string may appear in any of them

I am working with a table representing real people data, with a schema like this (MySQL Server): CREATE TABLE Users ( id INTEGER PRIMARY KEY, name NVARCHAR(32) NOT NULL, surname1 NVARCHAR(32)...
0
votes
1answer
28 views

How Do I Query this Data in Access Without Creating a Circular Reference

I have two tables called Events and EventSeasons. Events define the main type of events that there can be, and EventSeasons stores the number of times that the events have occurred yearly. I'm trying ...
1
vote
1answer
63 views

Anyone understand why this query no longer works? [closed]

On Localhost this query works correctly, running normal MySQL: SELECT COUNT(*) as rows, customers. * FROM customers WHERE user_id = 6 AND age = 10 ORDER BY timestamp DESC LIMIT 0 However ...
0
votes
1answer
13 views

Counting and grouping over multiple OUTER JOINs

I'm creating a view of advertisement logs (impressions, clicks, and clicks per impression). I have a simple table structure and some working queries but I'm having some trouble composing these into a ...
2
votes
1answer
55 views

Declarative and Procedural Query Languages

In the book Database System Concepts 6th Edition, Chapter 2 (Relational Algebra), it states that there are three formal query languages, the relational algebra, the tuple relational calculus and the ...
1
vote
1answer
17 views

query on 2 fields but 1 is a unique value

postgresql 9.6, windows 7 Here is an example of a database : fld1 fld2 abc D123 xyz D123 abc D789 how can I select rows with fld1='abc' if/only for fld2 value exists just one time in the ...
1
vote
2answers
27 views

Showing data that is not already in the data base

I have the following problem. I want to search a query in an existing data base and that the result shows me the entries of the query that are NOT already in the database. Minimal example: | ID | ...
-1
votes
0answers
17 views

Upgrade query with LEAD simulation in mysql

I'm here for ask how to upgrade this query localized in SQL Fiddle. There, we have column Time_Stamp with dates of two days diferrents, and value column where values they vary between 0 and 1 ...
0
votes
1answer
28 views

Obtain virtual column formula with SQL

We want to update the condition of a virtual column and to minimize error posibilites we want to extract the exact function working today to add new parameters to take into account. I've firstly test ...
1
vote
2answers
33 views

How to get average of lat/long from cities by county that they're in

I found this script but I'd like to get the average of the latitudes/longitudes so I can just have the latitude/longitude of the counties. I tried SELECT id, CITY, COUNTY, LONGITUDE, LATITUDE, AVG(...
-3
votes
1answer
28 views

Left join not working - not talking about my bones

I have two tables dbo.eletter: eletter_id eletter_title eletter_body eletter_form eletter_teacherID eletter_signed eletter_parentID dbo.status: status_id status_letterid status_parentid ...
1
vote
1answer
18 views

MySQL Computed Column counting other rows with attributes relative to this one

I have a table in a MySQL database that has information about passenger flights. I want to do some analysis of flight delays. I would like to add a calculated attribute to each row that indicates how ...
0
votes
1answer
29 views

Query to retrieve aggregated data using variables

Question: Summarise events using the MIN, MAX and COUNT functions Help: To do this, create variables to hold each of the aggregates: Variable What it will hold eventually --------------- -...
0
votes
1answer
16 views

MySQL 8.0 - SELECT QUERY

Hi I am having trouble with building a select query command with my tables. TABLE CUSTOMER +-----------------+-----------------+--------------+ | customer_number | customer_status | order_status | +-...
1
vote
2answers
25 views

Recommended Way to Store Logical Expressions

Say, I have the following SQL table: | ID | GameId | PlanId | MinAgeLimit | Amount | |:--------------|--------|-------------|-------:| | 1 | Cricket | P1 | 10 | 500 | | 2 | ...
0
votes
1answer
15 views

how can I extract values from one cell to make it multiple rows

if i had a table like this: ------------------------------------------ user | list_of_jobs | ------------------------------------------ 1 | [dentist] | [farmer] | [fisher]...