Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers. This question does not appear to be about programming within the scope defined in the help center. Closed 2 years ago. Improve this question I am having just a small problem with the name array, when i perfor…
SQL Query to return all rows with the earliest date available for each year
I am trying to design a SQL query that can return the records for the earliest date in each year. Suppose I have a table as follows: I am trying to generate a table shown below: The earliest date for each year will change, which means I cannot simply query by day & month. I have tried using: But this
SQL Query aggregate may not appear in WHERE clause (AVG)
Hi I can’t find a solution how to fix this problem. An aggregate may not appear in the WHERE clause unless it is in a subquery contained in a HAVING clause or a select list, and the column being aggregated is an outer reference. Should be like this : AVG is 28.3 so UnitPrice higher than 28.3 Having also…
The INSERT statement conflicted with the FOREIGN KEY constraint “FK__Messages__Email__3D9E16F4”
Maybe someone can tell me why this is happening. I wrote this stored procedure: Now I’m trying to check it by inserting: and I get: Msg 547, Level 16, State 0, Procedure Newmessages, Line 4 [Batch Start Line 0] > The INSERT statement conflicted with the FOREIGN KEY constraint “FK__Messages__Ema…
Find schema name given table name in Redshift
Is it possible to retrieve the schema name given the table name in redshift and return an error if table is not found? SELECT * FROM PG_TABLE_DEF WHERE tablename = ‘tablename’; doesn’t seem to work. Answer pg_table_def lets you see only the tables that are visible to your curent user ̵…
GBQ SQL: Using IF statement in a WHERE statement to filter data
Looking to filter data when multiple conditions are met. The table I have is below: I need to keep rows that fulfill either one of the follow criteria: If STOCK > 0 THEN KEEP ROW If STOCK <= 0 AND TIME is within 2 weeks from today THEN KEEP ROW The result table should look like this: For my WHERE
SQLite how to use UPDATE and LIMIT at the same time?
What I’m looking for is to update only 1 row in a table where all the entries are, in the beginning, zero. After a while surfing the internet for answers, I found out that LIMIT should work fine with UPDATE, but also not quite. From what I’ve seen, I should have “enabled” some stuff wi…
Update column, replace part of value
I’m trying to replace a specific piece of text. I have no experience at all with mysql. The table (content) has a column ( keywords ) containing all kind of words separated by comma. I want to replace tekst with text. Important: the whole string contains many other combined values with partly tekst in i…
SQL compare rows between groups and show the missing
I have the following data from a SQL DB. There are 98 columns in total this is an extract of 4 to illustrate what I would like to to and in the final query I would expect to require 51 of them. There are 15 million rows to this table. This table shows each change to a subscription. We can
BigQuery: need a clever solution for a difficult query
The context of this problem is a Live Chat service. Each conversation consists of multiple messages of which the timestamp is registred. Conversations are held in one or more channels, depending on the difficulty of the inquiry. The picture below shows an example of the data. For testing purposes the sheet ca…