Tuesday, July 11, 2006
One New Thing: More advanced SQL.
I saw a colleague do something with an SQL query today that I didn't know you could do: return a count(*) column for every row in a query that returns several rows.
For example, if you had a table of data on books of varying topics, you could query the number of books in each topic by using SELECT topic, count(*) and making sure you GROUP BY topic.
I've only ever used count(*) to SELECT one total count for one column, so this is a very exciting discovery for me. :)
In trying to learn more I googled around (this depth of information isn't in the w3schools SQL tutorial) and discovered this Word doc of SQL Tips. I have no idea what the context of the document is, but it's from a university website and the structure of the queries looks vaguely PeopleSoft-ish to me. If you're interested in learning SQL (or more SQL than you know already) finding pages of queries like this is a cool way to pick up how it works.
Comments: Post a Comment
Links to this post: