返回首页

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
0answers
3 views

Creating a table with 2 primary keys and two foreign keys referring to 2 different tables with same constraint name

Hey people Im new to RDBMS and have started to learn just recently , for this particular schema i have created the department student and subject tables now the problem right now arises in the ...
0
votes
0answers
12 views

When to pay attention to NULL values in SQL queries?

I know that you should not use the clause NOT IN when you have NULL values you're trying to compare to. Also, an arithmetic operation involving a NULL returns NULL. However in other situations NULL ...
0
votes
0answers
15 views

How can i query one table, and return the result as two tables

I want to query a table that contains a column with two types of data, and i want to get the result of this query as two separate tables so i can handle the data separately. The column contains : ...
0
votes
2answers
19 views

SQL MERGE only when changed

On a SQL MERGE how do I insert a "do nothing" type statement? For example, I have this right now: MERGE INTO dbo.Worker AS T USING dbo.Collector_Worker AS S ON T.WWID = S.WWID WHEN MATCHED THEN ...
0
votes
1answer
20 views

How can i select a many to many relationship table?

I have the following tables that im trying to pull data from. [ tutors ] [ majors ] [ courses ] [ bundle ] [bundle_courses] |id | |id | |id | |id | |id ...
-2
votes
0answers
18 views

Query to get a “inbox” of messages

+--------+--------+-------+-------+-------------------------+-----------------+-------------+------------+---------------------+- | id | active | owner | adid | smr_fmr_sfv_ffv_ssk_fsk | ...
0
votes
0answers
16 views

Multiple Oracle long running session created for single sqlID Transaction in Jboss7.1.1EAP and Oracle 11g

I am having problem with multiple long running session happening in Oracle DB causing performance issues. Can anyone point out what parameter I need to change to alleviate this pain in the Database ...
-3
votes
1answer
27 views

Prevent insert statement from reordering table in SQL

I am creating a foreign key table. The table will holds groupnames (as its primary key), which is referenced as a FK in the main table. Many objects in the main table might belong to one group. There ...
-1
votes
3answers
26 views

How can I switch the Month and Day when the column format is M/D/Y?

I am not sure if this has already been answered but I could not find anything. I am trying to convert the column of dates from MM/DD/YYYY to DD/MM/YYYY. I must confess that I don't even know where ...
-1
votes
0answers
23 views

MySQL says I am missing a comma, can't rename column [duplicate]

Command I am trying to run: ALTER TABLE users RENAME COLUMN pwd TO password; SQL error I'm getting: Missing comma before start of a new alter operation. (near "TO" at position 36) Is this a bug? ...
0
votes
1answer
11 views

pass multiple dates to foreach loop container

I have a process where I want to pass multiple dates that have not been loaded to my foreach loop container to iterate through dates one at a time. if there are no start dates in the table that have ...
0
votes
0answers
7 views

Full Backup/Restore vs Individual Table Copy for Daily Data Transfer

I am building an analysis SQL Server environment independent from a production server, and I need to get copies of the production data into my new environment on a daily basis. The production ...
1
vote
2answers
48 views

ORDER BY with multiple columns

I have the following in my sql statement ORDER BY CASE WHEN @OrderColumn = 'PointName' AND @Ordertype = 'ASC' THEN CD.PointName END ASC, CASE WHEN @OrderColumn = 'Name' AND @Ordertype = '...
0
votes
0answers
14 views

Slow query operation with recursive CTE

I have a query in which I use a recursive CTE. Unfortunately, when I'm extending the entry dates, the time increases significantly. Would anyone be able to help me how to change the code to make the ...
0
votes
2answers
28 views

trigger with increment

I'm studying triggers and I have trouble running one with a very simple increment. The triggers runs okay ( no error at execution, but what I meant to do with it is not the result it gives) This is my ...
1
vote
1answer
30 views

How do I create a SQL Trigger to alter multiple rows into another table?

I'm very new at SQL and starting to use the databases to connect with PowerApps and PowerBI. I had a question about triggers. I have a table (Table A) that contains three columns: ID, TotalQty & ...
0
votes
2answers
28 views

SQL Primary Key (ID) Auto start from beginning

I am using a 3rd party pricing API, the data is with start and end date with a price. I have checked that SQL database limits as follows; BIGINT Integer data from -2^63 through 2^63 - 1 INT ...
0
votes
2answers
26 views

Column Sum in SQL

I have the below query: select a.jobid ,a.jobnavn ,a.jobstart ,a.ExpTypeDescr ,b.Quote ,b.Expense ,b.Invoiced ,b.Actual from job a INNER JOIN JobAdjustmentDetails AS b ON a.jobid = b....
0
votes
2answers
22 views

How to Batch INSERT SQL Server?

I am trying to batch inserting rows from one table to another. DECLARE @batch INT = 10000; WHILE @batch > 0 BEGIN BEGIN TRANSACTION INSERT into table2 select top (@batch) * FROM ...
0
votes
1answer
13 views

SQLite3::SQLException: near “LIKE”: syntax error: Can you use more than one OR in sqllite3?

Trying to perform a search query in 4 different locations but when I run the query with more than one OR clause it gives me this error. SQLite3::SQLException: near "LIKE": syntax error: SELECT COUNT(*...
1
vote
0answers
19 views

Postgres - create table very slow - with partition and BRIN index

I have a table with over 260 million records. I have created partition for the table and also indexed it. CREATE TABLE qt_al_90k ( rec_id integer, user_id integer, user_text text, ...
0
votes
0answers
16 views

How do I insert multiple records using Dapper while also including other dynamic parameters?

Here is a truncated example of what I'm trying to do: var stuffTOSave = new List<SomeObject> { public int OtherTableId { get; set; } public List<Guid> ComponentIds { get; set; } };...
0
votes
4answers
29 views

SQL return most recent date & time stamp

I have the below data and need to see the most recent date where the action equals 'USED': CAT STAMP ACTION A 05/12/2019 00:13 USED A 05/12/2019 07:56 USED A 05/12/2019 09:...
0
votes
1answer
19 views

Not all parameters were used in the SQL statement using dataframe.to_sql

I am having trouble diagnosing an error using pandas dataframe.to_sql I first get my connection using connection = mysql.connector.connect Then I try to insert my data into the mysql database using ...
0
votes
0answers
39 views

Union leads to error converting varchar to numeric

I'm reposting my question from yesterday with the addition of code. I'm creating a new table LAB_RESULT as a union of two tables (Labs and CTE). A column called result_num (numeric (18,5)) is causing ...
1
vote
1answer
30 views

Starting select after specific value

here is my problem. I'm trying to select a list of records after a specific one, so starting from this value I want to select the next one (and not the starting value). My "filter" is a primary key, ...
0
votes
2answers
32 views

Insert foreign key into table with SQL query using C#

I have a database with 3 tables Identification, Identification_group and Group. The Identification_group table has 2 foreign key columns, Identificaiton_id and Group_id. In my form you can ...
0
votes
0answers
22 views

How to solve “Access denied using password:NO” in mySQL with Java Eclipse?

I'm making a java project with SceneBuilder and Eclipse; i need to connect to a local database created using MySQL, but after running my Java code in eclipse i get the following error: Exception in ...
0
votes
0answers
30 views

SQL code for finding jobs logged within +/- 1 day for the same site

I'm trying to set up a report to show me jobs that might potentially be duplicates. The criteria I want to use in the report is to show me all jobs for a specific job type, for a site, where there is ...
0
votes
2answers
20 views

Postgresql case statement returns empty row when condition is not met

I have the following statement in a query: CASE WHEN "PI".statusid_dec = 'Entered' and "PI".pagename = 'Procedural Information' and "PI".pishact IS NULL then 'ACT (Activated Clotting ...
0
votes
0answers
15 views

Saving data over time, like time series in google cloud SQL?

I wanted to know if it was possible to save data over time with google cloud SQL. Let me explain my need. Let's say my app is a racing game and I want to save the ranking of each player after a race....
1
vote
2answers
36 views

Constraint with regexp

I am currently trying to create a regular expresion to use in my Oracle database constraints' that is able to check if all the words of a string starts with an uppercase. I already tried to use ...
0
votes
1answer
22 views

SQL not working within a python function when printed reflects as a string

I am trying to run SQL code to retrieve data from IBM DB2 within a python function that is retrieving data from SAP GUI and based on certain criteria pull the data from IBM DB2. When i print the ...
0
votes
1answer
17 views

SQL Injection to enumerate the columns

Following query is used to fetch all the tables from the database 1 = select top 1 name from sys.tables where object_id = (select top 1 object_id from (select top 5 ...
0
votes
2answers
44 views

SQL Update table rows where the is a specific value

I have the following table in SQL server. It is called ScenarioData and I am using the data specifically the fieldValue column to append this data into a form. I have achieved this functionality but ...
3
votes
1answer
29 views

How can I efficiently paginate the results of a complex SQL query?

I have a fairly complex SQL query which first fetches some data into a CTE and then performs several self-joins on the CTE in order to compute a value. Here's an abberivated exmaple, with some ...
1
vote
2answers
65 views

SQL Reduce a value multiple times

I have a value from a table that I want to reduce for each percentage e.g. Table 1 ID Percentage FKID 1 5 1 2 10 1 3 4 1 Table 2 ID ...
0
votes
0answers
14 views

How to map data set result from ms sql function to CLR dto with EF 6 (including CLR collection types) [duplicate]

i would like to map data set result from ms sql user function to CLR dto with EF 6: MS sql function sample: CREATE PROCEDURE spTest @userName NVARCHAR(MAX) AS ...
0
votes
0answers
12 views

Create Nested AND + OR statements using addFieldToFilter Magento 2

Helo I have this "semi complex" sql query I want to perform using the addFieldToFilter() functionality of Magento2. I know how to define AND and OR statements using this logic however I'm strugeling ...
0
votes
1answer
28 views

Moving SQL record up or down Based on the number inserted or removed

I have a select list of records that have a number 1-10. The value for each <option> is the id from the record on the database and the text is another column value --- numToDo. (see below) <...
0
votes
0answers
28 views

Can't run two .sql in a single .bat file

I have a scheduled task with a .bat file that downloads some files from a web server every day by the morning then process the data and UPDATES a database. Then it triggers another .bat file to SELECT ...
-1
votes
1answer
32 views

Unknown Column in subquery where contain INNER JOIN

I have 3 tables: b2 table tb_stok table tb_barang table I intend to display the transaction_id column in the tb_stok table with 1 more column next to it called id_transaction which contains a ...
0
votes
0answers
16 views

SQL:How can i select a row with the less NULL? [closed]

How can i select from my table the row (NO COLUMN) with the less NULL?
0
votes
2answers
36 views

Oracle procedure to increment dates

I am trying to increment a date based upon a condition (while a date is bigger than the other): CREATE OR REPLACE PROCEDURE schema.procedura AS dt_lst DATE; dt_md DATE; eu_val INT; BEGIN for i ...
-2
votes
0answers
13 views

how to generate XML by SQL

I have a little problem. I want to generate an XML file from an SQL request. The file I need to generate should look like another file but I have to do it with SQL. Sometimes there are changes to the ...
1
vote
1answer
42 views

Join top n records from child table

I am struggling to figure out how to select only the first 4 records from a child table per record in the parent table in a master-detail relationship. Tables example: Product ProductImage --...
0
votes
2answers
42 views

saving multiple arrays to database asp.net

I am an intern and i don't get the guidance i need at my internship so i'm asking it here. string sql; sql = "INSERT INTO Uzk.Talen (Kantoor, Taal, Spreken, Lezen, Schrijven, ...
0
votes
0answers
21 views

return number of rows inserted into table

I have a SQL command that inserts some rows into a SQL table using Matlab. n = exec(db, sql); I use the exec function which works and inserts the rows from one table to another. However, I would ...
0
votes
0answers
10 views

Get all depencies to views and tables called thanks to a DBLINK in oracle

I have a DB "myDB" in oracle with a DBLINK "MyDBLink" pointing on another oracle DB "MyOriginalDB". The connection is working. I create several tables and views in MyOriginalDB and I created views in "...
0
votes
1answer
23 views

How does RANK() work on multiple columns in Sql?

Could you please explain how does this piece of SQL work? QUALIFY selects first value, it's clear QUALIFY RANK(column1 ASC, column2 ASC, column3 , column4)=1 What does Rank() do with next columns ...

返回首页
杏彩计划 杏彩官网 杏彩APP 杏彩走势图 杏彩下载 杏彩官方 杏彩网站 杏彩怎么玩 杏彩官方 杏彩靠谱吗 杏彩代理 杏彩骗局 杏彩投注 杏彩倍率 杏彩开奖 杏彩漏洞