I use this SQL query to insert 1 row of data: Is it possible with 1 SQL query to insert 100 rows with random data into Postgre table? Answer
How to find all records that are older than or equal to the current month of the previous year?
I barely know SQL. I am trying to achieve the following: For example I have the following table that has 2 fields I need to find all whose birthdays are current month of the previous year and prior. For example if I am running the query on 08/15/2021, I need to find all records that have a month/date of 08/20…
Find Individuals who have purchased 10 times within a rolling 1 year period
So let’s say I have 2 tables. One table is for consumers, and another is for sales. Consumers ID Name … 1 John Johns … 2 Cathy Dans … Sales ID consumer_id purchase_date … 1 1 01/03/05 … 2 1 02/04/10 … 3 1 03/04/11 … 4 2 02/14/07 … 5 2 09/24/08 … 6 2 …
How to parse comma delimited list and join those values on another table and reconcatenate? [closed]
Closed. This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed last year. The community reviewed whether to reopen this question last year and left it closed: Original close reason(s) were n…
ORACLE DATETIME ROUND UP WHEN MINUTES 0
I have a datetime: I need to round up just when the minutes are different to 00. Example: 1/1/2000 2:37:00 AM => should be => 1/1/2000 3:00:00 AM. (dont round up if hour =00) 1/1/2000 2:00:00 AM => should be => 1/1/2000 2:00:00 AM For now my code has round function but this one look the nearest ho…
How do i link different rows of database into buttons and display the appropriate informations?
Below is the php page and code i created to display information from two rows of the database. This is the picture of my database. And this is the code and page where the user will be redirected to after clicking the ‘More Information’ button. What I am actually trying to do is to make the booking…
Subquery to get derived value
I have the below table T in MySQL, with columns A and B. I want to query this table to get a value ‘C’, that has the count of the number of times the value in Column ‘A’ appears in Column ‘B’. For example, 1 appears 2 times in Column B, so the first row of column C should b…
Generate a random number for each group and assign it to all rows in the group
I have a table in the form The goal is to group the table by ID and for each group, select a random number from the number of groups (in this case, select a random number from [1, 3]) and assign all rows of each group one number. One possible configuration is I was thinking of using ROW_NUMBER() and PARTITION…
SQL 30 day active user query
I have a table of users and how many events they fired on a given date: DATE USERID EVENTS 2021-08-27 1 5 2021-07-25 1 7 2021-07-23 2 3 2021-07-20 3 9 2021-06-22 1 9 2021-05-05 1 4 2021-05-05 2 2 2021-05-05 3 6 2021-05-05 4 8 2021-05-05 5 1 I want to create a table showing number of active users
Why are my counts different when using CASE operator VS IF function?
I learnt that the difference between CASE and IF statement is as follows “IF is a CASE with only one ‘WHEN’ statement”. But I got confused when querying this: I have the table Olympics which contains the countries and medals associated to it. I am counting the total number of medals wo…