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.
I want to get sum of day sale report with condition
Payment method like cash and card should be club as one line and other payment as new line
CREATE TABLE IF NOT EXISTS `sale` (
`ID` int(6) ...
Have some trouble with this error in my code.
Expected tokens [EOF]. Found token [GROUP] (Line: 61, Column: 1)
All I'm doing is a query on union all between statements. My code looks something like ...
I am running one sql query to fetch records from a table with multiple threads. Initially all the threads go in INACTIVE status and slowly it starts coming to ACTIVE status.
I have created HASH ...
I have a table naed mkpfs_store and have 2 columns: creon(timestamp) and original_creon(date). I want to save the values from creon to original_creon.
Following is my query:
UPDATE mkpfs_store SET `...
I have a data from 1 to N, and what I need to do is to make it fall into intervals with a step of five. For example every item from 1 to 5 goes to interval 1, from 6 to 10 into interval 2 and so on ...
In the DolphinDB table, how do I match the date with the time? When my date is greater than 10, there will be an error. What should I do?
fv = table(2012.12.01 2012.12.12 2012.12.13 as date, 12:12:...
I was trying to display the number of days between two dates(column) in my database. The output display was in the varchar data type. How should I convert it into int data type? Following is the error ...
I am trying to list a number of missing records in the DB, as described in my unanswered question here
I am now attempting to fill a temp table with data that should be checked, and comparing that ...
I need to sort data of multiple columns for my node.js api all the columns return data in no particular sequence. I am using following query.I need all the columns in sequence either alphabetical or ...
I have this table. How to loop over each row, apply for it the code below and set IsAzure column to 1 or 0 (according to result from the code).
Something like this from C#, but using sql
Good day to all. So I have lots of data in excel that i needed to insert in the db but I didn't notice I inserted a duplicate value (cause hr didn't sort it out).
So anyways, here is the deal
I have 2 tables:
I have a table with multilinestrings and I would like to find a line which starts at a certain point. I am using:
gis=> select * from (select gid, ST_StartPoint(ST_LineMerge((geom))) as start ...
I have This Data
DocDate Sector Zone InvQty ReturnQty FreeQty ReturnQtyAmt DscrdQty DscrdQtyAmt
27-06-2019 LHR A 30 14 0 182 14 182
I am running the following queries in SQL.
SELECT @serial := IF((@thisid != `places`.`id`), @serial + 1, @serial) as `serial`, @thisid := `places`.`id`, `places`.`id` ...
i want to replace ids with coresponding values
example:if column consist of ids 1,2
I need to replace 1 with "Product Videos",2 with "Installation" .
I can use case but not able to find a way to use ...
I have a big table with data like this:
2 01_SOMESTRING K5038
I have two tables:
How do you create a stored procedure that will update all the Code ...
There is a column in Select clause NVL(b.name, a.name) and I am using this column in Order By due to which the Oracle query has become slow.
I tried creating index on the NAME column but of no use.
I want the min and max marks for each student. Below are the sample marks,
I want the uc_min as whatever coming before / and uc_max as whatever coming as after /
Below is my code, It is not working ...
I am trying to filter only valid values contained in the typed text of a JComboBox which is read from the database.
E.g From DB, i have 'Makindu', 'Mombasa'.
If i type 'a' both the 2 values should ...
To clarify my problem I have created a test table with the following structure.
CREATE TABLE public.test_large (
id int4 NOT NULL, -- Primary Key
grp int4 NULL, -- Group ID
descr text ...
I wrote a Java app that generates a report.
While generating the report it stops and the stack trace gives me this error:
java.sql.SQLException: Closed Resultset: next
In my DB, there are two tables
ID (Primary key)
ID (Primary key)
EventTypeID (foreign key)
ParentActivityTypeID (Relation with self ID)
I have tried with the ...
Hi I have a requirement of finding the occurrence percentage of specific items in a group. My table is like this
Team Objective Status
Team1 Obj1 ...
I left join 5 tables and insert the select result into my target table,
200,000 records costed 30s before I add a new left join in the statement. However,after the addtion of the new left join,the sql ...
I have to replace special characters in SQL.
My problem is with ', because it is used for start and end of string in SQL.
ID = REPLACE(ID, ''', '')
ID = REPLACE(ID, "'", "")
But both not ...
TableOne: LNAME FNAME FILETYPE
Smith John A
Jones Mary B
Brown James B
TableTwo: NAME FILETYPE
I have got a table here which shows the amount of sales done for a particular date for 3 companies.
I need to find the minimum and the maximum sales done for a company and on which date the sales was ...
Currently I am using dynamic data table bootstrap 4 and I want to add pagination in my table
EF6, asp mvc core and SQL server are used on the background.
I have to do many queries to the same table with different conditions, f.e.
SELECT COUNT(*) FROM Table1 WHERE a = true
SELECT COUNT(*) ...
I have incoming json structure like
I'm struggling to find a simple way to save or retrieve the contents of the currently focused file (without saving) via custom task in VS Code.
I've been building a custom task to "run" a report from ...
Write a query to display list of students name who all are from IT department. Sort the result based on students name in descending.
I'm setting up a directory page that displays different workouts depending on what is searched through a text field(which works) and/or checkboxes(Doesn't work)
I don't know if it's possible without ...
I am working on a problem where there is a demand table in Postgres that updates once every week. I am attempting to build a script that automates that data pull and shows the differences in weekly ...
I need to rollback the previous version of dacpac using DveOps/VSTS.
If any limitation and it is possible?
Please give me any ideas.
I have 2 tables (I've only shown select fields):
Table B (A lookup table):
I have a filter dropdown list with the following options in it:
1, 2, 3, 4, 5, Other
When the user selects an option I will run a simple SQL query to filter the data by that value such as:
Need to create a SQL AD account and grant read access to the master database on all SQL servers using PowerShell script. Below script helps in creating AD account on a single instance.
$sqlServer = ...
My SQL code produce per_month, per_month min, per_month max and per_month standard deviation. But i have done it with CTE. now i want to do without CTE.
;WITH QTY_T AS(
I can't transform one column to multiple columns and multiple columns to rows.
The best way to explain myself would be with the table.
I want to know how mysql 5.7 engine works the same as sum over part.
Cannot replace query engine because it is not a personal operation.
There was an attempt to resolve it through the @set variable ...
I will need to list down duplicate functions within the responsibility name in Oracle
I have tried the below sql query
select ffl.user_function_name, ff.function_name, rtl.responsibility_name
I'm trying to check if a column exists within a given table.
When checking if it exists, I want to update the column with the value 1, if not, create and update.
However, every time I run the error, ...
Very simply, let's say I have want to SUM the total of a feature within a group.
So I partition over a window function:
SELECT sum(NumberOfPlayers) over (partition by sport) as SumOfSport
I'm developing a database for a medium size software where we are going to have a lot of records created daily, right now I do not have an approximated number but I would guess something around 7k to ...
I have table which td is contenteditable. To update the value of td in my database I decide to use localStorage. Once the button save is click the inputted value in td will save to localStorage and ...
The question is how show tidy result in one server when glogin.sql is empty?
Did not want to use this code in glogin.sql for every db server:
-- Defaults for SHOW PARAMETERS
I am using MySQL and want to create a query that will count how many times appointments happened per contact_id within the last year, last year, and how many times the occurrence happened overall.