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

JOIN queries not working in Node-postgres

I'm trying to query two relational tables together using Node-postgres, but getting a syntax error: ;(async () => { const client = await pool.connect() try { const ...
0
votes
0answers
3 views

Fulltext score taking a long time to calculate

I have a query that returns 5 records in 14.6ms. Just a basic query on an index: SELECT eidr_id # match(search) against ('warncdfomMPMd4153463 105240E244CC76351C744DC9B9') x FROM ...
0
votes
0answers
9 views

Report showing column name where should be showing value of the field in SSRS

I am currently developing a report using SSRS. I have a column called 'FROM' and it is INT data type. I am setting the field correctly but somehow it shows 'from' in the report. I set up the ...
0
votes
0answers
13 views

Query to view the date and time a row was last updated for table without having an existing trigger\mechanism?

I'm sure this is going to be a hard no, but I have a table that I need to know the last update date and time for one particular row, written in the past. Is there a way to find this information? ...
1
vote
1answer
17 views

postgresql Cross Tab syntax error: No function matches the given name and argument types. You might need to add explicit type casts

I am trying to create a cross tab, but it is giving me an error: No function matches the given name and argument types. You might need to add explicit type casts. Here is my query for creating a ...
1
vote
2answers
16 views

ORA-01873 when calculating the difference between two timestamps

I am trying to produce the number of days between two timestamps, as a precise fractional number. My code is producing ORA-01873: the leading precision of the interval is too small This single line ...
0
votes
0answers
10 views

populate listbox from an sql query (VBNET) [duplicate]

so basically what I want to do is populate the contents of a listbox with the result of an SQL query but I haven't done this before and so don't know how I can do this. This is what I have so far ...
0
votes
1answer
8 views

Can i use Oracle No sql database on a android app

Pretty straight forward developing a android app and instead of using a relation database i want to use a graph database any help would be greatly appreciated thank you.
0
votes
1answer
13 views

Charting the data from database and merging row with the same value

I want to create chart that read the category column in my database.. I have repeating category because its general term and i notice this. i have many "short" slice.. i dont have any idea how to ...
0
votes
0answers
10 views

Azure Stream Analytics Query Returns 0 rows

I have data coming in from KEPServerEx with nested lists, so I need to CROSS APPLY to send individual values to my blob from the incoming stream. I had the query working for a few minutes utilizing ...
1
vote
1answer
21 views

MySQL Get unique conversation and last messages ordered by date

I'm making a messaging system. I want to retrieve specific user's conversations with content (this user can be both sender or receiver) ordered by date. I looked for every question online but none of ...
-1
votes
0answers
30 views

Write a UNION to always return a result set?

I have a query that returns an OrgID, Total Annual Wage, and Wage Effective Date from the Actual_Pay_Hours table. Additionally, there is another table called Combo_Table_Detail which contains Wage ...
0
votes
2answers
20 views

SQL Default value current date and time

So I have this table created: CREATE TABLE Hospital_MedicalRecord( recNo CHAR(5), patient CHAR(9), doctor CHAR(9), enteredOn DATE NOT NULL, diagnosis VARCHAR(50) NOT NULL, ...
0
votes
1answer
17 views

SQLite JSON query to count number of items in nested list

I'm trying to query a database in which a column contains JSON data. I am using python and the json1 extension to pull the queries into my python code. A sample of the data within the json inside the ...
0
votes
2answers
18 views

postgresql: syntax error for creating a function that determines the differences in dates

I would like to write a function that calculates the difference in two dates. Here is my function: CREATE OR REPLACE FUNCTION order_prep_days(ship_date DATE, order_date DATE) returns 'ship_date - ...
0
votes
1answer
24 views

SUM function generates error in SQL query

I'm trying to get information about an SQL table via a php script however, whenever I add a SUM function I get the following error "Notice: Trying to get property 'num_rows' of non-object" I don't ...
-1
votes
0answers
13 views

I can't install postgresql-simple on haskell

When I write this command: cabal install postgres-simple or cabal install postgresql-simple This error appears: cabal: Error: some packages failed to install: postgresql-libpg-0.9.4.2 failed during ...
0
votes
0answers
13 views

Access VBA if then else compare 2 tables if values are not null

I am trying to run a validation query on 2 tables, Pages and Section. The query works but if the Pages table values (equipment model and equipment serial prefix) are null then it returns any value as ...
0
votes
0answers
20 views

speeding up seek pagination with complex queries

I am working on an API with an underlying MySQL database. I have some complex queries that involve multiple joins and some of these tables are huge (> 200 million rows). I am using seek pagination ...
1
vote
2answers
31 views

SQL select row if column equal to row

I got this table: | NINumber | fname | lname | mentored_by | --------------------------------------------- | DD1199XYZ | John | Smith | DD234CD1X | | DD0094CYY | Barry | Gibbson | DD0094CYY ...
0
votes
0answers
14 views

ORA-00942 with cx_Oracle

I'm trying to run any command on an autonomous database from oracle cloud after establishing connection but they don't seem to work. cursor.execute("select * from admin.customers") gives me the ...
0
votes
0answers
24 views

ORA-01722: Invalid Number - 01722 The Specified Number was Invalid

Can someone please point me in the right direction with this query? SELECT A.EMPLID, C.ACCOUNT_BALANCE, (sum(case when A.ITEM_TYPE BETWEEN 700000000000 AND 799999999999 ...
-1
votes
0answers
16 views

SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens ERROR received when trying to run a query [duplicate]

Can anyone tell me why am I getting " SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens" Error when I try to run the code below? Thanks $sql = $...
-1
votes
3answers
47 views

Display only records which are not duplicated

I wish to display only records which have no duplicate. CREATE TABLE #TempTbl1 ( Circuit varchar(55), Bandwidth decimal(7,1), Unit bit, CurrentID int, ); INSERT INTO #TempTbl1 VALUES ...
0
votes
1answer
27 views

Query to “PIVOT” the results of SalesAmount & CumulativeMonthly for ALL YEARS

I have a database table that captures every Sales Transaction: Transactions ( ID INT, TransactionDate DATETIME, SalesAmount MONEY ) I need to run a T-SQL query to product a Sales ...
0
votes
1answer
64 views

Why is “IS NOT NULL” in SQL Server still returning NULL values?

I am trying to exclude NULL values from my result. However"IS NOT NULL" seems to be not working. I attempted below and included screen shots of my sql code as well as the output in a speadsheet. The ...
1
vote
0answers
22 views

Python: Creating tables in SQlite, MySQL or Postgres with user input as table name?

Is it possible to create a table with a user's input as the name of the table? c.execute("""CREATE TABLE *User input*( license_no integer, ...
0
votes
0answers
15 views

SQL JS Bulk INsert

var elements = [{ "name": "1", "age": 11 }, { "name": "2", "age": 22 }, { "name": 3, "age": 33 }...
0
votes
1answer
22 views

How to use query result and query again using LIKE statement in Laravel

I am trying to use questions result and get question again if title has some char in it. If I query in condition_question table, I get results as expected. public function showQuestions($category) ...
-2
votes
4answers
39 views

how to use SQL get the MAX and MIN from a SUM(quantity) table group by gender [closed]

I have a table shown as below: ________________________________ ID | quantity | in/out | __________|___________|________| 1 10 in 2 20 in 3 ...
0
votes
0answers
4 views

Save data to database Using WPF datagrid with checkbox using MVVM pattern

I am looking for an example I have looked everywhere but no luck. What I am trying to accomplish: + I have loaded data into datagrid, I have a checkbox column I want to check single or multiple ...
0
votes
1answer
25 views

Count of difference in values by date

I have a data set that contain two columns [date, cust_id]. date cust_id 2019-12-08 123 2019-12-08 321 2019-12-09 123 2019-12-09 456 There is a high churn rate for my customers and I ...
1
vote
2answers
24 views

Need to import from a data xml file to oracle sql developer and for creating Table

as i said in the title, i would like to import data from a xml file to oracle sql developer for creating a table, but it failed. Here is my code : drop table cata; create table cata( filename ...
-4
votes
0answers
42 views

Does unique or index property creates a non-clustered index?

We have a table for users with the columns below: (Primary Key) user-id (Index) username password (Unique Constraint) email (Unique Constraint) phone_number I already know that a primary key ...
1
vote
2answers
40 views

Selecting unique players' scores from two columns with bubble sorting

I have a very interesting challenge that I'm either looking too hard at (and missing a simple solution), or it is more complex than I can figure out heh Essentially, I have a game that tracks scores. ...
-1
votes
0answers
30 views

Efficient way to create all combinations of conditions and modifiers as SQL views

First off I'd like to apoligize if the wording of this question is weird or off, I really don't know how to word it better. The core idea I'm trying to solve is creating a bunch of views of a single ...
0
votes
1answer
16 views

Selecting zipcode that is stored in string as numberic range (hive)

I'd like to select people who live in california zipcodes. However this table i'm using stores zipcodes as string, instead of integers, so I havre to put a qutoe around it. How can I select these ...
-1
votes
1answer
33 views

Current time -1 hour [duplicate]

I have the following column that is made using the following function to_char(to_date(f.f_sto_sta_dt_id, 'YYYYMMDD') + (f.f_sto_sta_ti_id/86400), 'YYYY-MM-DD HH24:MI:SS') as sto_sta dt_cur T1 ...
-1
votes
1answer
23 views

Select Earliest Date from List of Distinct Employee numbers

SELECT a1.[employee_number], a1.[class_id], a1.[TraineeAddedOn], a1.[TraineeRemovedOn], a1.[effective_start_date], a2.REHIRE FROM TrainingAnalytics_Staging.....
0
votes
1answer
25 views

postgresql: how to import data from two separate tables into a single table into the SAME row?

I am using postgresql to create countries table from single_sales_records. single_sales_records looks like this: sales_id |region |country| <Many other columns!> ------...
0
votes
1answer
27 views

How to update 0 or null values with sequence number?

I need to update the values 0 and null in column batch so that the value continue the sequence for the year. The new value should start from the lowest 0/null value for the year. id year batch 1 ...
1
vote
3answers
27 views

ORACLE CREATE TABLE with FOREIGN KEY error

I am a beginner to Oracle and have been having problems creating a table with a foreign key, I have created the parent table region as well and have been receiving the same error. I have researched on ...
0
votes
0answers
24 views

What do you think of this approach? I want to reuse data from previous functions to avoid calling twice the same function

So I have three functions involved in the process of obtaining information about a customer: A function executing an SQL query to the database, A function making some complex calculations with the ...
0
votes
1answer
21 views

Linked Server unable to begin a distributed transaction - SQL Server

I am end user on SQL Server 2016 (SP2-CU7-GDR). I am trying to execute a query of the following nature: DECLARE @sqlcode VARCHAR(MAX) SET @sqlcode = 'proprietary sql code' TRUNCATE TABLE [...
0
votes
1answer
19 views

SQL Convert Binary Hex representation to string keeping same output

I have the following SQL Server query DECLARE @StartRange BINARY(8) DECLARE @EndRange BINARY(8) SET @StartRange = 0x0000004A50F119B SET @EndRange = 0x00000004A50F11FF SELECT CONVERT(BINARY(6),...
0
votes
3answers
38 views

T-SQL query to summarize sales for ALL YEARS: with total per month per year, and cumulative monthly amounts

I need to create a Sales Report that shows all years sales per month, and cumulative sales. The database table is simple: Transactions ( ID INT, TransactionDate DATETIME, ...
-1
votes
1answer
27 views

ORA-01403: no data found ORA-06512

This question has been asked here before so please forgive me for asking again; the answers did not resolve my issue. I'm working on a report interface that will run stored procedures from an Oracle ...
0
votes
1answer
21 views

How to add a string before all values in a column— Using Redshift

I have a table that looks like this: field1,field2 dummydata,dummydata dummydata,dummydata dummydata,dummydata dummydata,dummydata I want to write a Redshift Query to adds v1_ to the beginning of ...
0
votes
2answers
30 views

Dynamically select table names from VS Data tool

I have a SSIS package that syncs data from source to destination Tables. However I am looking for a solution where whenever the package runs it automatically selects table from previous month i.e. (...
1
vote
1answer
36 views

Passing variable inside query using python

I am using below code to upload file from local machine into SQL server. Currently, code correctly picks the file from hardcoded location and stores into DB. How to pass variable name instead of ...