I want to display how many days an item was in each stage. We have many items, so just showing one ID for now for simplicity. For first stage it should be action_date -created time. For last stage it …
Tag: sql
SQL function delete rows with a specific date and a specific value on another column
I have a question, mostly about syntax. I have a sql table and I need to delete some rows based on the date on a “Date” column as long as they contain a string in a “Client” column My issue is the …
Uncaught mysqli_sql_exception: You have an error in your SQL syntax
I cant get my update button to work, my SQL syntax isnt targeting the datebase properly, this is the syntax im using $sql = (“UPDATE crud SET name=’$name’, last=’$last’, email=’$email’, birthday=’$…
SQL (Oracle) – Select where record does not exist or another column in the 2nd table is true
Applications-Table ——————— ID FIRST_NAME LAST_NAME APPLICATION_TYPE STATUS_TYPE 123 JOHN SMITH EDUCATION …
How to insert rows in SQLite using default values?
Update: Here is what I have learned from the answers below… SQLite supports defining default values on columns. However, it does not support any form of DEFAULT keyword or function in queries. So, …
Read table[columns] and display in console
I have one table and about 20 columns which contain more than 5000 rows. Right now I want to display all 20 columns in console, and I came to thirth column and I get error Here is my code: This peace of code make me error When I change this to Anyone can guide me and tell me what’s wrong
MySql last record from group by item_id with order by date
My database table name is ledgers and fields are id, item_id, date, …other fields I Want the last record from (groupBy item_id order by date ASC). from each group. I tried below query Can you guys please help. Answer You can filter with a correlated subquery: For performance, consider an index on (item_…
how to use NULLIF with aggregate function
I’m using SQL Management Studio 2012. I’m getting a ‘Divide by zero error encountered’ error. I’m aware this requires the use of NULLIF but I’m unsure how to use it in my query. This is my query I’ve actually asked this question before which some kind person answered …
SQL QUERY TO SHOW FIRST IN AND FIRST OUT
my query like this : output getting : BUT I NEED TO SHOW THE RESULT LIKE THIS Answer Assuming that your in and outs are interleaved, you can use row_number() and aggregation: For your particular query, this is a little simpler:
SQL Server Lag and Lead
I’m using SQL Server 2014. I have a table: I have some data: If I perform a LAG and LEAD using the below for one Job, I get the desired result: Result: Notice the NULL for the first FromActionCode and LastToCode, which is correct. However, If I look at all records, it messes it up: What am I missing? An…