Are Postgres SELECT DISTINCT queries deterministic? Will SELECT DISTINCT somecolumn FROM sometable return the same result (including order) if the table (and entire database) goes unchanged? In the Select Query Documentation the Description section notes: If the ORDER BY clause is specified, the returned rows are sorted in the specified order. If ORDER BY is not given, the rows are
Tag: select
behavior of DBMS after executing where clause
in a select query when some records doesn’t satisfy the condition in where clause, they will be omitted for executing subsequent clauses or not? for example consider we have a group by clause and after that, we have a condition in having clause on max(someThing). if a record has the maximum value of property someThing and it didn’t satisfy the
How to make it to select from 1st day every month
Hello there I have a question so I have a goal mysqli query and it sum the price and select by interval 1 month I try few things to made it to select only from 1st day of the month but I have no idea …
How to select from string array added in SQL column?
Below is my table, tried its not working for i want to select rows by passing colPar as ‘param1,param2’ so it will result me all the records containing param1 and param2 in colParam Answer This quiet tricky. to Return all matching values. Output:
SQL query to select previous 14 months where add amount ‘0’ if any month is missing
I have create this query to select the date, amount for previous 14 months, In this case the month is missing if no record is present for that month, Please suggest me a solution to add zero and month …
SQL: INSERT multiple different hardcoded values in one column
I could not find a solution for this yet. I want to insert multiple rows with 2 or more different hardcoded values, but also with data that I get from another table. Example: I want to add 2 items into a table for a user that has the ID = ‘0’ in another table without running 2 queries. This is
Comparing group-by result with aggregated result
I am trying to retrieve details about stores where their average product prices are higher than the average of all stores in the table. So far, I have this code: select StoreID, count(ProductID) …
How to Find Unique Rows without GroupBy, Distinct
I have a SQL field that I only want to appear in a field in my sql query results depending on the value of FamilyType. So when the Family Type is 3B then I want FamilyID to appear. I do not want to have duplicate rows (without using distinct or group by or where clause = 3B). These are my
How to merge rows into one row with separator
I need merge rows into one row for summary of calculation (SQL Server 2014). My SQL query is: Result of this query is: I would like to have this result: When add new currency (x), the result of new currency must be appended: Can somebody please help me with this topic? Many thanks Answer Something like this should work with
Find the manager details where all the employees under the manager should have salary more than 1000
Im having the table with records like below and i need to get the manager details where the all the employees under the manager should have salary more than 1000 Answer Here is a solution that uses a correlated subquery: This ensures that: the selected employee is a manager (ie they manage at least one employee) all of the managees