ORA-00904: invalid identifier

Your problem is those pernicious double quotes. Oracle SQL allows us to ignore the case of database object names provided we either create them with names all in upper case, or without using double quotes. If we use mixed case or lower case in the script and wrapped the identifiers in double quotes we are … Read more

What is a stored procedure?

Stored procedures are a batch of SQL statements that can be executed in a couple of ways. Most major DBMs support stored procedures; however, not all do. You will need to verify with your particular DBMS help documentation for specifics. As I am most familiar with SQL Server I will use that as my samples. … Read more

Case in Select Statement

I have an SQL statement that has a CASE from SELECT and I just can’t get it right. Can you guys show me an example of CASE where the cases are the conditions and the results are from the cases. For example: where the results show

Selecting COUNT(*) with DISTINCT

Count all the DISTINCT program names by program type and push number DISTINCT COUNT(*) will return a row for each unique count. What you want is COUNT(DISTINCT <expression>): evaluates expression for each row in a group and returns the number of unique, non-null values.

What is the difference between UNION and UNION ALL?

UNION removes duplicate records (where all columns in the results are the same), UNION ALL does not. There is a performance hit when using UNION instead of UNION ALL, since the database server must do additional work to remove the duplicate rows, but usually you do not want the duplicates (especially when developing reports). UNION Example: Result: UNION ALL example: Result:

MySQL Error: : ‘Access denied for user ‘root’@’localhost’

Open & Edit /etc/my.cnf or /etc/mysql/my.cnf, depending on your distro. Add skip-grant-tables under [mysqld] Restart Mysql You should be able to login to mysql now using the below command mysql -u root -p Run mysql> flush privileges; Set new password by ALTER USER ‘root’@’localhost’ IDENTIFIED BY ‘NewPassword’; Go back to /etc/my.cnf and remove/comment skip-grant-tables Restart Mysql Now you will be able to login with the new … Read more

MySQL Error: : ‘Access denied for user ‘root’@’localhost’

Open & Edit /etc/my.cnf or /etc/mysql/my.cnf, depending on your distro. Add skip-grant-tables under [mysqld] Restart Mysql You should be able to login to mysql now using the below command mysql -u root -p Run mysql> flush privileges; Set new password by ALTER USER ‘root’@’localhost’ IDENTIFIED BY ‘NewPassword’; Go back to /etc/my.cnf and remove/comment skip-grant-tables Restart Mysql Now you will be able to login with the new … Read more