Skip to content

Tag: sql

How to count occurrences of a column value efficiently in SQL?

I have a table of students: I want to query for all students, and an additional column that counts how many students are of the same age: What’s the most efficient way of doing this? I fear that a sub-query will be slow, and I’m wondering if there’s a better way. Is there? Answer This should…

T-SQL – Aliasing using “=” versus “as” [closed]

Closed. This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 3 years ago. This post was edited and submitted for review last month and failed to reopen the post: Ori…

PHP MySQL INSERT return value with one query execution

Is there anything returned from MySQL/PHP on a INSERT query being executed? Here is my function which I have in a CLASS. This is how I call the function But executing a INSERT query the $rs returns nothing. Does my function need help or is this the default behavior? Any tips would be helpful as well. Answer I…

Combining OUTER JOIN and WHERE

I’m trying to fetch some data from a database. I want to select an employee, and if available, all appointments and other data related to that employee. This is the query: SELECT TA.id, TEI….

Changing INT to BigInt

I have a warehouse table with 16 tons of data in it. I have a few Integer columns in it. We have to cast these into BIGINT for every query we write, because the SUM is too large to fit in an INT. We now have a new datamart under development. So we thought, why not change all these columns