Questions tagged [sql]

Lô đề online Structured Query Language (SQL) is a language for querying databases. Questions should include code examples, table structure, sample data, and a tag for the DBMS implementation (e.g. MySQL, PostgreSQL, Oracle, MS SQL Server, IBM DB2, etc.) being used. If your question relates solely to a specific DBMS (uses specific extensions/features), use that DBMS's tag instead. Answers to questions tagged with SQL should use ISO/IEC standard SQL.

Filter by
Sorted by
Tagged with
0
votes
0answers
10 views

Get the maximum field from a list of objects by sql

@Query("SELECT new ru.users.model.UserDto(b.userId, COUNT(b)) " + " FROM UserEntity b where b.status = 'SUCCESS' " + "AND b.userId IN (:ids) &...
-1
votes
1answer
15 views

Passing table for JOIN using CASE WHEN statement

I'm trying to use a CASE WHEN statement to determine which table to use for the latter half of a JOIN. For example, there are 3 tables: TableA, TableB, TableC. SELECT a.column1, b.column2 FROM TableA ...
0
votes
1answer
10 views

PostgreSQL - Insert where not exists in another table / Reverse Foreign Key?

I have two tables: Records and Notifications in a PostgreSQL database The flow of logic is that I am going to be receiving many messages, which will be stored into the Notifications table. Every once ...
0
votes
0answers
21 views

Index size on VARCHAR column

In trying to index a VARCHAR(256) fields I get the following error: MySQL said: Index column size too large. The maximum column size is 767 bytes. It works using VARCHAR(255) but I'm curious why ...
0
votes
1answer
17 views

Mysql - sum time difference and group per hour

I've ask recently question about grouping data per hour, but I will try to extend and explain more. Currently I've managed to organized the structure like this: ChangeDate | ChangeTime | timediff | +-...
0
votes
0answers
14 views

como evitar esta circularidad en tablas, si necesito que al alumno y profesor se les asigne un campus y una licenciatura [closed]

enter image description here necesito saber como quitar la circularidad entre las tablas o dejar autónomo el catalogo de campus_carreras
-1
votes
1answer
49 views

How do I CREATE A table in SQL

I'm very new to SQL and my insert statement triggers an error in SQL. Is there an error in my CREATE TABLE syntax? I have gone through it but can not seem to find anything right now. String videos = &...
0
votes
0answers
7 views

Creating a trigger on Azure SQL

I am trying to send telemetry messages into a database whose architecture is below. I currently have 5 tables, whose columns are the following: Table Device : DeviceID (PK), Firmware Table RawMessage ...
0
votes
1answer
20 views

PostgreSQL: Update multiple rows in table with a single query

Suppose I have a table Car. This table has the following columns: id(uuid), status(text), color(text). I have pushed all the Car ids that have a specific color into an array: Suppose I have an array ...
1
vote
2answers
25 views

MySQL: Is there a way to select a column and use it in “multiple ways”?

I'm learning MySQL and I'm facing a problem that I cannot find an answer to. I have a database that includes columns: company and company_response. I have now queried the companies in a descending ...
0
votes
1answer
22 views

How to get a value between a range of varchar string in SQL

I need to search for a value between two strings that are varchar. I have two tables: #Code: StartList EndList Code 1 3 A 4 7 B 20 25 C 1a 1e ...
0
votes
1answer
33 views

Comparing Aggregates in SQL

List the suppliers whose aggregate order summed by weight (p.weight x sp.qty) is greater than that on order by supplier “S2,” list supplier number, name and aggregate weight of parts on order by ...
0
votes
1answer
25 views

sql order by with an inner select clause and group by rollup

My query looks like below with the foll. output Current Output Role Cases prepped % Completed State Member 1 10 5 50% State Member 2 10 7 70% State President 10 2 ...
1
vote
2answers
23 views

SQL Server 2012 - Rolling counter with reset

I am using SQL Server 2012 and want to get total of login unsuccessful attempts. My table has | Login_Name | Is_Success | Login_Date | My query is select login_name, sum(case when is_success = 1 ...
-1
votes
0answers
26 views

SQL Statement to convert Currency

I am trying to create a SQL Statement that would give all the rows in the 'Order Line Transaction Fact' Table converted into a different Currency. For example, lets say Local currency is CAD and we ...

15 30 50 per page
1
2 3 4 5
37720