I have a table of patient visits, where each row is a visit. There is a column with the unique patient ID to signify which client the visit was for. I would like to add another column which shows the Nth occurrence of that patient ID within the data-set. So first visit would show 1, second visit shows 2 and
Tag: sql
MySQL query get total of payments for everyday of the month until current date
I’m trying to build a MySQL query to get the total amount for every day of the month until the current date. I’m not sure if it’s possible with just one query. It would be something like: Today’s date = ‘2021-02-24’ In the end, I would have the total amount for every day. D…
replace all column values equal to one string with another string
I have a MYSQL table called traceclasses and I have a column in this table called value with some of its cell values equal to E as shown below. I would like to replace all such values with U. Which query should I use to do this? Answer You are looking for update:
Oracle how to select and update one field value and insert records quickly
We have the below scenario: create table create table tt (id number, name varchar2(30), note varchar2(4)); insert into tt values (1,’AC’,’m’); insert into tt values (2,’Test’,’f’); we want to select …
Convert array of timestamps in PostgreSQL (not in a table)
I need to get this command: to work for an array (or in rows). Reason is that I have a lot of timestamps that need to be converted and if I use the above structure, I just end up adding lots of columns that my front-end can’t handle. My current solution is to actually dump all of the timestamps into
Returning values from 2 select statements in Oracle Procedure
Homework question that I’m stuck on. I need to create a Procedure called dept_info with a department id as the IN parameter with department name and full name (concat of first and last name) of the manager of that department as the OUT parameters to be passed back to the invoking program. the procedure …
SQL Query with Excel VBA
I’m trying to run a SQL query with Excel VBA. I got the query from someone else. When I run this query, I’m getting the following error message: “The SELECT statement includes a reserve word or an argument name that is misspelled or missing, or the punctuation is incorrect.” I can̵…
how to replace ids with names in sql from another table?
I have a table passenger_count pas1_id pas2_id count 1 6 2 14 37 4 that connects by pas_id with another table passenger: id name 1 Bruce k 2 George L 3 Li Wo 4 Don Wa How to replace pas1_id, pas2_id with actual names from passenger table? This self join query does not work: Answer Just join passenger to passe…
Inserting an ID that increments (but is not an AUTOINCREMENT)
I have a table that I am trying to insert multiple records into using a select statement. The ID field is an INT and not autoincremented but I do need to increment in in the INSERT. The table belongs to a third party product we use for our ERP so I cannot change the property of the ID. The insert
Out of Range Error while inserting into a MySQL decimal column
I have this tabular structure: I get an error when i try to insert a specific set of value, query with those values is as below: For longitude with value -161.9722021 it is throwing me an error, values less than 100 value were successfully inserted. I don’t see the value being out of range, the value i …