Skip to content
Advertisement

Using group by on multiple columns

I understand the point of GROUP BY x. But how does GROUP BY x, y work, and what does it mean? Answer Group By X means put all those with the same value for X in the one group. Group By X, Y means put all those with the same values for both X and Y in the one group.

practicing WHERE and HAVING in SQL

here is the schema: alt text http://img30.imageshack.us/img30/3324/123vk.jpg here is the question: Point out the battles in which at least three ships from the same country took part. here is my …

How to debug PDO database queries?

Before moving to PDO, I created SQL queries in PHP by concatenating strings. If I got database syntax error, I could just echo the final SQL query string, try it myself on the database, and tweak it …

SQL: difference between PARTITION BY and GROUP BY

I’ve been using GROUP BY for all types of aggregate queries over the years. Recently, I’ve been reverse-engineering some code that uses PARTITION BY to perform aggregations. In reading through all the documentation I can find about PARTITION BY, it sounds a lot like GROUP BY, maybe with a little extra functionality added in. Are they two versions of the

How to find unused tables in SQL Server

Is there a way of finding out when the data was last entered into a table? I’m trying to find obsolete tables within my database and would like to know if there is a simple script(s) that I can run? Answer You could try check the results of querying the sys.dm_db_index_usage_stats Dynamic Management View like this: This will return things

Advertisement