When I input a code or anything into MySQL and hit “enter” it moves down and “->” appears. It is as if the code is not going through or the code is not being read. I have attempted to download “add-ons” but I am really not sure what I am doing. This is for school and I a…
Tag: sql
SQL how to find continuous count of rows that exceed a value over time
I need to figure out how to query this table such that I find out the continuous count for each ID in which the value is equal or above 1 and the timestamp1 is bigger than timestamp 2. So for example: ID 1 will have a count of 2 because the 3rd row is 0 and even though the 4th
SQL Stored Procedure Parameters Being Assigned to Variables
I’m sure there is some sound logic/best practice but I’d like it explained to me if possible. Looking at SQL stored procedures written by a previous employee he always declares 1 variable for each parameter and sets the variable equal to the parameter value and then uses the variable throughout th…
Can I Select DISTINCT on 2 columns and Sum grouped by 1 column in one query?
Is it possible to write one query, where I would group by 2 columns in a table to get the count of total members plus get a sum of one column in that same table, but grouped by one column? For example, the data looks like this I want to get a count on distinct combinations of columns “OHID” and
Mysql use 2 functions in 1 query
I’m trying to use 2 same functions in 1 query which is this This uses only the first function and give right result for the first latlngs only. I need the row which is almost near to the 2 latlngs (the latlngs is just example don’t care if it’s wrong <3 ) I want it to Give me the row
Android studio SQL – How to return data in a string array
I have an SQL method here. I would like to return the data in a String[] array. How do I do that exactly? Thank you! Answer You must define the array’s length and this can be done only after the Cursor fetches all the rows. Then set its length to the nimber of rows of the Cursor. Then inside the
postgresql: relation “table_name” does not exist when trying to CREATE TABLE
I am running this code thru pgAdmin4: i am keep getting this message: ERROR: relation “supplier” does not exist SQL state: 42P01 The problem is with the foreign key in the product table (1st table), i know this because i removed it and it created all the tables with values (i removed some of the v…
mysql query question about removing data from columns
This is what the table looks like right. I only want to delete the data in the two columns on the right. So let’s say i want to delete the first row Aheadworks_AdvancedSearch columns on the right. I’m sorry i’m horrible in mysql. Would this be the right syntax? How can i combine as well? Ans…
How to make generic SQL heredocs?
I’m making a mock ORM in Ruby, storing ‘forum’ data. I have the following tables: users (id, fname, lname), and questions (id, title, body, author_id). a_user.create and a_question.create are more or less the same: I’m writing another class, ModelBase, and I’d like to be able to …
Proper way of getting rows since a date accounting for DST?
I have a datetime column, changedate, that I need to use to get rows that have changed in the last week since 1PM. This column is unfortunately in local time (EST). The server is Microsoft SQL Server 2016. Here is the query I have now: Since I’m using AT TIME ZONE for both the column and @since, will th…