I have two database tables that look something like this: Context: Booking_Statuses is used to retain a history of the various stages that a booking can go through, such as PENDING or ACCEPTED, so I can construct a timeline of events for the booking. One Booking has many Booking_Statuses. I’m using PostgreSQL. I am trying to query the bookings for
Tag: sql
How to group by only year in DQL?
How can I translate this query to Doctrine Query Language Answer Since your query only needs to group by year from a datetime column, you will need the YEAR function, which is not supported by default in DQL. You can install DoctrineExtensions which will add the functionality you need. And then edit the doctrine config file (config/packages/doctrine.yaml) as follow: Now
How to show data that’s not in a table. SQL ORACLE
I’ve a data base with two tables. I need a SQL query which show “The players who have not won any game”. I tried but I don’t know even how to begin. Thank you Answer You need all the rows from players that don’t have corresponding rows in wins. For this you need a left join, filtering for rows that
Get all the names were total purchases are >70% of all the purchases per client
I have information about places and purchases in a table, and I need to find the name of all the places where, for all the clients who purchased in that place, the total of their purchases is at least 70%. I’ve already found the answer on python, I’ve sum the number of purchases per client, then the purchases per client
Query to pull the data from 3 tables based on latest load date and HashKey
I am trying write a SQL query to pull the data from 3 tables using JOINS on basis of common HashKey and I want to take all the updated records from 3rd table based on the load date(last increment/recent records) using SQL. I have tried below SQL query but I am not able to get the recent record from third
How to select best customers and group them by how much they paid
I am using SQL server to select this table and group the customer id and first name according to their total payments made to the store. I tried using but it returns the following error: not contained in either an aggregate function or the GROUP BY clause Could you please clarify what I did wrong? this is my customer table
Combine multiple selects for statistics generation into on result set
Hey Pros, I am far away to have good knowledge about SQL, and would ask you to give me some hints. Currently we aggregate our data with python and I would try to switch this when possible to. (SQL (Postgresql server) My goal is to have one statment that generate an average for two seperates column’s for specific time intervals
Connect to local database on other computers
How can I use my LocalDB on other computers? I tried this but it doesn’t work because I get this error: Local Database Runtime error occurred. Cannot create an automatic instance Does someone know how to fix this, or what I can do instead? I don’t want to use SQLServer because I am making a program for an offline computer.
How do I select rows that are not recent and are different from the last entry?
How do I select rows that are not recent and are different from the last entry? We recognize the differences by context field. My example DB: I would like to retrieve from try table rows with id: 4, 7, 8 and 11. I tried the following: But I have got the following error: ERROR 1242 (21000) at line 120: Subquery
JdbcTemplate SELECT query to get unique rows (each row with unique ID is present once)
Anyone willing to help me out with one jdbctemplate query? Need to get only rows with unique id’s but there are duplicates, because other columns, such as date have different values. I need to get the max date preferably and the resultset should not have any duplicates. 😡 output: This almost works, but not quite. There are duplicates sadly. Here’s