Tags: sql

SQL query: select five most commented posts from different blogs


I have a following tables Blogs(id) and Posts(id, blog_id, comment_count) I need to select five most commented posts from different blogs. It’s quite easy to do with a function, but is it possible to …


How do you avoid column name conflicts?

I was recently assigned a task of creating an auction system. During my work, I met numerous occasions where my SQL queries that contained joins failed to execute due to ambiguous column names. …

ORA-00054 Resource busy when dropping table

Tags: , , ,

Can somebody explain this error? ORA-00054: Resource busy and aquire with NOWAIT specified This error came in a DROP TABLE. Because of it, procedures and packages are not getting compiled.


Is there a way to make this SQL more efficient?

Consider the following tables: department deptid (type:INT) deptname (type: TEXT) hours (type:INT) active (type:BIT) employee empid (type:INT) empname (type: TEXT) …


MySQL Integer 0 vs NULL

When using integer columns is it better to have 0 or NULL to indicate no value. For example, if a table had a parent_id field and a particular entry had no parent, would you use 0 or NULL? I have …

SQL and escaped XML data

Tags: , ,

I have a table with a mix of escaped and non-escaped XML. Of course, the data I need is escaped. For example, I have: <…

Drop multiple tables in one shot in mysql

Tags: , , ,

How to drop multiple tables from one single database at one command. something like, > use test; > drop table a,b,c; where a,b,c are the tables from database test.

How do I find the largest value in a column in postgres sql?

Tags: , ,

For example: name | weight jon 100 jane 120 joe 130 How do I only return the name of the person with the largest weight?

Tags: sql sql-server

How to sort Varchar Date in SQL Server 2000

Tags: ,

My table schema (table Name Stock) Field Date Datetime If Date having datatype is Datetime then SQL Server sorts the date in well/perfect order. See Below Example. select date from stock order by …

Tags: pyodbc python sql

SQL IN operator using pyodbc and SQL Server

Tags: , ,

I’m using pyodbc to query to an SQL Server database import datetime import pyodbc conn = pyodbc.connect(“Driver={SQL Server};Server=’dbserver’,Database=’db’, …