New answers tagged

2 votes

Is it possible to mysqldump a subset of a database required to reproduce a query?

This question is quite old and already has some good answers provided. One possible solution is to use mysqldump with the --where option. However, in recent years, several new products have been ...
0 votes
Accepted

combine multiple sql with same FROM clause and diff where clause

The most important issue is to ensure that the aggregations return the same results in the combined query as they do in the separate queries. You achieve the correctness by making your aggregations ...
  • 22.4k
0 votes

combine multiple sql with same FROM clause and diff where clause

You can do this by combining the WHERE clauses SELECT AVG(ST_Distance_Sphere( point(`event`.`event_location_longitude`,`event`.`event_location_latitude`), point(`user`.`...
2 votes

Name of SQL programming style where KEYWORDS | CRITERIA are justified to centering line

A possible name for the programming style you are looking for would be vertical aligned. However, there is no actual standard as to how the vertical aligned style would be implemented into whatever ...
2 votes

Name of SQL programming style where KEYWORDS | CRITERIA are justified to centering line

GUI tools have/might have formatting options which allow you to set your own preferences. For example, in TOAD, it looks like this: In Oracle SQL Developer: Million years ago, when we were on Oracle ...
0 votes

MySQL Select query for a calculated column that uses previous row value for current row

SELECT *, CASE month WHEN 1 THEN salary WHEN 2 THEN LAG(salary) OVER (PARTITION BY employee ORDER BY month) + 10 ELSE LAG(salary) OVER (PARTITION BY ...
  • 18.6k
2 votes
Accepted

Selecting second highest value using two SQL queries returns different results

These queries are fundamentally different. One has a scalar aggregation, and one does not. This query is selecting the first row which is not the maximum. If there is no row then no results will be ...
  • 8,965
0 votes

PostgreSQL, INSERT INTO SELECT DISTINCT generates more rows?

So I finally deduplicated it but not inside the PostgreSQL DB, I used COPY to export the table in CSV format, then used sort -u to deduplicate it, once it's done I re-used COPY to import the CSV file ...
  • 11
2 votes

PostgreSQL, INSERT INTO SELECT DISTINCT generates more rows?

Running SELECT DISTINCT on a table with no (useful) indexes will require a sort on the entire result set, which will likely spill to disk given the table size, in addition to the actual rows inserted ...
  • 23.9k

Top 50 recent answers are included