I want only results WHERE COUNT = 0, but every way I tried making this query it failed. Please help! Answer Use HAVING. For example: HAVING filters “resulting rows” after they are aggregated. WHERE, on the other side, filters rows before they are aggregated. Or… you can use an anti-join:
Tag: sql
Save few values to the row in Postgres [closed]
Closed. This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 3 months ago. Improve this question Is it possible to save few values to the row. For example, I have 2 tables: For Participants: And for Voters: I want to get
Check all possible connection exists
I want to check for all connections between two table exists and return all rows specifying weather the connections exists or not for example here is my tables: Permissions: index Controller Action 5 Error index 2 Home index 3 Home login 4 Home logout 1 Test index 9 UserManagement createUser 8 UserManagement editUser 6 UserManagement index Roles_Permissions: Roles Permissions 1
How to flip a bit switch based on events in date sequence without using SQL CURSOR?
I have a list of dates, with occasional events that correspond to start and stop dates for periods, and I want to flip a bit switch for all dates which occur between start and stop. Example: (Obviously just a pseudocode example). Is there a way to join these two tables without using a cursor and get the following result: I
Query that counts total records per day and total records with same time timestamp and id per day in Bigquery
I have timeseries data like this: time id value 2018-04-25 22:00:00 UTC A 1 2018-04-25 23:00:00 UTC A 2 2018-04-25 23:00:00 UTC A 2.1 2018-04-25 23:00:00 UTC B 1 2018-04-26 23:00:00 UTC B 1.3 How do i write a query to produce an output table with these columns: date: the truncated time records: the number of records during this date
How do I used distinct to remove duplicates in this query?
I have the following table: Table I am trying to write a query (that I will include in another query) to display how many account numbers there are per symbol. I wrote the following query: The query displays like this but it counts the same account number multiple times per symbol. EURUSD should have 3 and USDJPY should only have
SQL Query for the Last 6 Months of users registered
I have created a query that shows the last 3 months of users registered to my site and currently have it grouped by day to show on a line graph. I would prefer to show it Grouped by Week on the line graph but have been unable to change my query successfully. Here is what I have written so far:
How can I return the Maximum Letters for a particular location using SQL?
I have the following table: TicketNumber FullName Type ActionTaken CPZName DateReceived DateResponded A306250992 Robson de Souza letter Re-issue Notice Lannisport 06/09/2022 2022/10/06 10:35:48 A306180194 Rivaldo Vitor Borba Ferreira email Re-issue Notice Lannisport NULL 2022/01/06 12:07:05 A306054145 Ronaldo de Assis Moreira User Note Hold For 14 Days Jurassic Park 06/09/2022 2022/11/06 20:53:16 A307716063 Wayne Mark Rooney email Re-Offer Discount Atlantis NULL
SQL STUFF FOR XML with specific grouping
I’m working in SQL Server 2014, and I have the following simple data, which tracks calling history of users: I need to group the ACTIVITY values into one field, which effortlessly be done using the STUFF FOR XML function: However I need to conditionally group these, on the condition that there was more than a 90 day between the activity
BigQuery finding sessions that have visited both pageA (contains keyword “main”) and pageB (contains keyword “side”)
On BQ I’m trying to find sessions that have visited both pageA (URL contains keyword “main”) and pageB (URL contains keyword “side”), and the pages that session visited. Here is my logic, I first wanted to find out sessions that have visited pageAs (URL contains keyword “main”), then I wanted to do a join, so to find out those sessions