Skip to content
Advertisement

Tag: group-by

group by issue in sql

i’m trying to get in a new column the sessions who are between 08:00 and 18:00. You can see my last CASE in the CTE. For each date there should be a new column “TotalRestrictedSessions” which indicate how many session were on that particular date. If there are none, in this case i have to write 0. I suspect that

Group by multiple columns and limit per group – Postgres

I’m creating a messaging app as a side project and I’m trying to query a user’s conversations efficiently. The messages table structure is basic right now with some dummy data: I’d like to be able to query the DB and group by “conversation” – A.K.A any rows that have the same sender_id or receiver_id in either column – rows (1,

Convert different dates in date column to rows in SQL Server

I want to display different dates as columns from LOGDATE column. Here are the details My query: This query returns this result: Expected output format: I have multiple types of SERVICE_TYPE and SERVICE_NAME, not just the three sown in the sample. How can I get my expected output? Any help would be appreciated. Answer You can do conditional aggregation to

SQL statement about average

My question is -> Retrieve the segment ID and length of each segment that is longer than the average length of all segments. Name the column indicating the length of segments “Length”. Relations: What I got so far is: And I got this error message: Error: Your query has syntax errors. Description: java.sql.SQLException: ORA-00979: not a GROUP BY expression Can

Advertisement