Questions tagged [sql]

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
-1
votes
0answers
14 views

How to calculate total hours from multiple in time and out time from below?

first punch as in time, second punch as out time if possible avoid duplicate punch on same time within a minute I need to get all in time ,outtime in a row with total hours like below any format. I ...
-2
votes
0answers
13 views

How to replace and sort positions in MySql

I have a problem with sort after replace 2 items position in MySQL. Example I use drag-drop in frontend and frontend sent me 2 indexes. from to indexes and I must change the position of this item in ...
-2
votes
0answers
18 views

#1064 - You have an error in your SQL syntax: add a primary key to my table admins

I want to add a primary key to my table admins But a get this error: #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right ...
0
votes
1answer
22 views

More Elegant way to Batch Validate Phone Numbers

I've got this test database that I want to use for validating a phone numbers. http://sqlfiddle.com/#!17/18a38/3 However it currently only works with a single number at a time. SELECT countries....
0
votes
1answer
18 views

How to delete values of one table based on multiple values from two tables

I have two tables: Table 1 = products (id, name, organisationId, subcategoryId) Table 2 = products_attribute_attributes (productId, attributeId) I am trying to delete from Table 2 where attributes ...
-1
votes
0answers
9 views

Searchable data form - php? SQL? [on hold]

I have a question regarding a search form. I have data that contains a lot of tasks that can be sorted by name, start time, end time, duration, department and all sorts of things. I am trying to ...
0
votes
1answer
14 views

SQL find parent where children match over multiple rows

I have a database where one user has multiple submission and one submission has multiple post I would like to find all users who have made posts with the tag "car" and posts with the tag "bike". ...
-1
votes
0answers
16 views

Internal drive storage for SQL Server

I am trying to do some SQL Server practice in my PC but I am not able to set up SQL Server on my PC. I did not get any local login or windows authentication like option. My friend told me to just ...
0
votes
0answers
14 views

A combo box that has to be filter the same data in that field

I need to make a combo box (drop-down box) that would include Cities and city1 is placed multiple times likewise city2,city3,city4...etc ComboBox Should show the Filtered City1, City2, one after one, ...
-3
votes
0answers
19 views

customers who have not made any orders in the months of January-March [on hold]

I have 2 tables Customers with typical column names and Orders with typical column names and OrderDate with DATETIME datatype which is having date from 1996 to 1998. Eg: "1997-06-02 00:00:00.000". I ...
0
votes
2answers
32 views

Why do I get an error when I execute SQL query “Create Table Tablename As”

Why do I get an error when I execute the below T-SQL query? CREATE TABLE TblCustomer AS (SELECT * FROM Customer); Msg 156, Level 15, State 1, Line 1 Incorrect syntax near the keyword 'AS' I ...
-4
votes
0answers
29 views

admin set two date limits and user select between those date, in php [on hold]

Exam Planner for Administrative staff for planning that declaring no. of Exam days and within these days student/user select one day.I am confused how to do in php and mysql.help me please like admin ...
0
votes
0answers
12 views

How to view an .sql file in text format (with sha512)

I have two seperate files; one .sql and one .sql.sha512 (1kb). And I need help to be able to view this .sql file in text format. I was using this .sql file years ago thanks to a friend of mine who ...
-1
votes
0answers
18 views

over riding the not instantiatable method of abstract class in oracle sql [on hold]

I have created an abstract class called samples create or replace type samples as object( name varchar(30), member function get_name return varchar, not final not instantiable member function ...
-1
votes
4answers
37 views

To get output of movie with its genre

I am writing a program to get an output of movies with there genre. sample database Movie movie_id , title (1, snitch) genre genre_id , genre (1, Action)(2, Animation)(3, Drama)(4, ...
0
votes
2answers
30 views

Create table as select from is creating duplicate records

I am trying to create a table as select from another table which is creating duplicate records. Meaning my SQL statement is returning me approx 11 million rows and my new table is returning me 15 ...
0
votes
1answer
39 views

why is it deadlock?

I just want add next date row. It is simple task, but it took 13 hours. Please help. update m4 set m4.nday = m3.nday from [stock].dbo.logday m4 join ( select stockcode, ...
-1
votes
0answers
31 views

Problem with sql schedule table and preserving old data using JOIN

I'm pretty new to sql, so forgive me if there's a simple answer. I'm setting up a scheduling database for lessons in a school. Each class has between 3 and 9 students. I was originally planning to use ...
0
votes
0answers
26 views

Running SQL script from Jenkins

I have a Jenkins job that does the following - 1) SSH into a server 2) Run a psql script The script runs for 4 hours when I run it manually, but every time I run it from Jenkins it stops at 1 hr ...
0
votes
0answers
24 views

Entity Framework Core Update using Generic Repository but only certain fields

Every single Generic Repository I see is just like this public async Task UpdateAsync<T>(T entity) where T : class { this.dbContext.Set<T>().Update(entity); _ = ...
-3
votes
1answer
15 views

SQL/ SEARCHING TO SEE IF TWO OR MORE DIFFERENT STUDENTS' IDs HAVE THE SAME CLASS ID [on hold]

Consider the following table ST_NAME || ST_ID || CLASS_ID || CLASS_INFO --------------------------------------------- MARK || 1 || 100 || MATH YEN || 2 || ...
0
votes
0answers
20 views

SQL: how do I maintain a running total that resets after reaching a certain threshold?

if I have a simple table that has a person ID and a date, and many rows per person with different dates, how can I track how many days passed from one date to the next, and reset the count once I ...
0
votes
1answer
12 views

Exclude updated record from trigger function

I have a table with a column named priority. I created a trigger function that fires after update. I want the function to change the values of the rest of the rows' priority column. For example I ...
0
votes
1answer
15 views

Insert into table from select only when select returns valid rows

I want to insert into table from select statement but it is required that insert only happens when select returns valid rows. If no rows return from select, then no insertion happens. insert into ...
0
votes
1answer
17 views

How to fix SQLite3::SQLException: near “to”: syntax error: SELECT “”.* FROM “” WHERE “”.“” = ? AND (to < '[Time.now]') LIMIT ? OFFSET?

I am developing a Rails application and using SQLite3 as my database server. I am having an issue querying conferences that have a to date_time that is less than Time.now. Here is the exact statement ...
1
vote
2answers
18 views

Trigger compiles but doesn't insert rows

I'm trying to create a TRIGGER that when fired inserts the data into a another table with USER and SYSDATE data. The script but no data is inserted from the TRIGGER. I'm running Oracle Server. ...
-3
votes
2answers
31 views

Getting error “Unknown column 'text' in 'field list'”

I am trying to insert text to my database table reqviews. But I get the error message: Unknown column 'text' in 'field list'. I'm not sure what's wrong with my code. Please help if (isset($_POST['...
0
votes
0answers
20 views

How to use multi SELECT in node RestAPI

I'm working on a REST API in node with express. I trying to make a GET method which should return datas from my database. My request is working perfectly on MySQL workbench. But when I put the exact ...
0
votes
0answers
31 views

SQL: How to return “Muñoz” when user queries “Munoz?”

I'm writing a stored procedure for use by English speakers that returns a person's surname. The surname in my table might be Muñoz, but my user, being an English speaker who doesn't frequently use ...
0
votes
1answer
15 views

Return records after doing some manipulation on them

I'm creating a web service that takes a mobile number in fixed format (+country code rest of the number ) and I need to return some data based on that number. The problem is the mobile numbers stored ...
-1
votes
0answers
16 views

Related to date formatting in excel

I am importing date timestamp by converting unix timestamp into dd/mm/yyyy hh:mm format using find_unixtime function in hive into excel, please let me know how can I convert this timestamp in excel ...
0
votes
0answers
21 views

INSERT INTO Error: SQLITE_ERROR: no such table: comments

I'm setting up a server for a project that I've been trying to develop on my own, and using SQLite and Node.js as the database type and server platform, respectively. I'm relatively new to backend ...
0
votes
2answers
34 views

Function to Parse Arrays in JSON to Insert Into a SQL Table

Trying to take a web API's JSON response and populate a SQL database with the results. Part of the JSON response has this array: "MediaLinks": [ { "MediaType": "...
0
votes
1answer
32 views

How to extract day from oracle function without using sub-query?

I have the query below is not working for me, this function from_tz(to_timestamp(START_TIME, 'YYYYMMDDHH24MISS'), substr(UTC_TIME_CODE_OFFSET,1,3)||':'||'00') at local as local_tstz allow me to ...
2
votes
2answers
45 views

Remove duplicate row based on specific column value

I have a table data like +--------------------------------------+--------------------------------------+-----------+--------+ | conversationid | participantid ...
0
votes
1answer
44 views

How can I update a view with or without a join?

I notice an issue about my SQL command. The company's database have a View that is based on 5 tables. Here is the structor / code for the email_view_test: create view [dbo].[email_view_test] as ...
0
votes
1answer
39 views

Stored procedure with group by

I have a table with data like this I am trying to create a stored procedure where it groups by lastname, firstname, npi, client id so I get something like 1 record for row 1 and 3 but with a comma ...
2
votes
1answer
27 views

Reset sum when condition is met in Oracle

My data is structured as follows: Timestamp | Hour | Count -------------------------- 20190801 01 | 1 | 10 20190801 02 | 2 | 20 20190801 03 | 3 | 10 20190801 04 | 4 | 5 ...
0
votes
0answers
13 views

Oracle DDL Trigger error - RDSADMIN.RDS_DDL_TRIGGER

On Oracle 11g, While calling a procedure through web application, which creates a temporary table inside, I am facing an error as RDSADMIN.RDS_DDL_TRIGGER error. While searching for this issue, we ...
4
votes
1answer
28 views

Date Between (Start & Now)

Not sure how to use the NOW() function in presto. Seems like it should be straight forward, but i'm getting no luck SELECT DISTINCT field FROM table WHERE field BETWEEN '2019-01-01' and NOW() field =...
0
votes
0answers
17 views

Column found in more than one table error

I'm getting the following error Error while compiling statement: FAILED: SemanticException Column episodeid Found in more than one tables/subqueries [SQL State=42000, DB Errorcode=40000] ...
-2
votes
1answer
47 views

picking off data from a string

Need help figuring out how exactly to break down a filepath to get the relevant details, For ex: I have a fielapath like '\192.168.50.100\folder\march\filetypeA\filenameB How do I extract the month, ...
1
vote
1answer
34 views

Reset running sum when condition is met in Oracle

My data is structured as follows: Timestamp | Hour | Count -------------------------- 20190801 01 | 1 | 10 20190801 02 | 2 | 20 20190801 03 | 3 | 10 20190801 04 | 4 | 5 ...
0
votes
0answers
13 views

SQL : Joining two time series data and computing totals and ratios from a given point in time

For my project, I have two data sets/series. One is my customers by registration date and another is the billing per month for each customer. The first series starts off in 2012 and the second starts ...
0
votes
1answer
19 views

Checking SQL Syntax Against MariaDB Syntax

I am converting a series of databases to reference MariaDB instead of using SQL Anywhere. Since there are some minor syntax differences between these two, I'd like to check that my existing SQL ...
1
vote
2answers
32 views

Why is my date criteria filtering incorrectly in a MsysObjects query using DCount?

I have an Access database with ~500 tables, and with a total of ~16,000 total rows across all tables. I would like to count the number of rows whose "datecreated" field is before January 1, 2019. I ...
1
vote
1answer
23 views

Stripping date/time delimiters in an SSIS csv export

I am exporting a csv from a table query via SSIS export. I would like to be able to strip the spaces, colons, fractions of the seconds, and dashes out of the datetime field when the export to csv ...
0
votes
1answer
23 views

What could be the code for putting existing auto increment id in order?

I am trying to learn more about SQL, now I see there is something, when I delete something from the table it leaves that id empty like if I delete 8 and then insert new data it creates id 10. But ...
1
vote
1answer
23 views

From sp_BlitzIndex I see “Table metadata not in memory” - What does this actually mean?

Is this saying something about the statistics for the index (or table?). I see stats for the non-clustered index as well as the clustered. Does it mean something else? This is from Brent Ozar's ...
2
votes
2answers
38 views

How to get values greater than or equal to in Mysql database sql when its a value like 1:00 PM?

I'm trying make an sql query that uses the users current time as a variable formatted like "11:30 AM". Then, finds records greater than equal to that in the mysql db. if(isset($_GET['curday'])){ $...