When using SQL database, when I have tables with same attributes. For example if I have [posts] with attributes (id, image, description, number of likes and dislikes) [Comments] with attributes (id, image, description, number of likes and dislikes) and [Replies] with attributes (id, image, description, number of likes and dislikes) and I have another type of posts, comments, replies for
How to group by multiple rows and column
For each user 3 codes are there(10,20,30) if all codes(10,20,30) are true then it has to JOINED if any codes(10,20,30) are False then it has to NEGLECTED WE have to check max(date) Table is below: Output user2 and user3 is JOINED, user1 is NEGLECTED Answer I assume that the column bool is of data type BOOL, so you can do
How to get the sum of specific entry in mysql?
For example if I want to get the agent codes whose sum of order amount is greater than 4000. what query should I use in mysql? My table is as follows:
Filter rows by whether a text column contains any words in a string in SQL
My SQL Server database table has a column text which is a long string of text. The search list is a string of words separated by comma. I want to grab those rows where the text column contains any …
How to break a row into multiple rows based on a column value in Athena (Presto)?
I have a Athena table that has a column containing array of values. I want to create multiple rows from one row such that the column of array can be changed to contain only 1 value. E.g. : to look like : How can I write my query to achieve this? Answer I think unnest() does what you want:
Using DATEADD instead of less than or equal to when testing against parameters
I’m newer to SQL and I’m playing around with some existing queries in my database in SSMS – something I’ve been coming across lately is this line: WHERE DE.Modified >=@FromDate AND DE.Modified <…
MySQL Spatial Join on Closest Point
I’ve looked around a bit and found quite a few people seeking to order a table of points by distance to a set point, but I’m curious how one would go about efficiently joining two tables on the …
how to get a list of all years from the mySQL
+————+—————+————+ | date | other_columns | date2 | +————+—————+————+ | 2019-05-23 | # | 2018-04-12 | +————+———–…
Unable to pass varchar datatype as input parameter in my SQL function
Unable to pass varchar2 datatype in my function. Below is my code: create or replace function f1(i varchar2) return varchar is j varchar2(10); begin select last_name into j from …
How to prevent table locking with multiple users writing and reading from table at the same time?
I have a program I wrote for a group that is constantly writing, reading and deleting per session per user to our SQL server. I do not need to worry about what is being written or deleted as all the …