I'm storing user data (username, email, password hash) in PostgreSQL, and I can only enforce uniqueness on username. I'd like to let users provide either their username or their email when they login. ...

Using below query i want to find out the top number of students from each catagory(SC,ST,OBC,etc) on plus2percentage basis. eg i want top 3 students from SC catagory, top 2 from ST and Top3 from OBC. ...

I have a table names 'scoredata' having fields
id, lessonid, levelid, studentid, addedate
in which score for each day will be entered by the admin.
I want to select only those studentid whose score ...

Is it possible to get a result as a column?
The SELECT query will only need to return one record, however, at the time of querying the database it will not know what attributes are in the table, and ...

I want to get get 6 "double_scoring" records and 4 "singe_scoring" records from my Profiles table based on SCORING_RULE column values. Can you please let me know how can I do this with SELECT query ...

Look at the following example starting from the top row (id=9) and work your way down, selecting a limit of 4 rows that have sec's that we have not yet seen. We "select" id=9 because we don't yet have ...

I would like to create a function that queries a user table by passing a username and a password, the function is supposed to return 'Y' if the username / password are correct and 'N' if they're not.
...

Can you help me to solve a problem. The task is to insert a record in MySQL database.
terms:
If the record exists - to update the record.
If the record does not exist - to create a new one.
The Key ...

In MySQL, does SELECT performance degrade significantly after a certain table size? I have a table with about 107 million rows and some queries seem stuck in "Sending data" for a long time. Of course, ...

What I'd like to do is order my query so that the results show every row found, but are ordered by showing results that begin with the letter 'D' first. Is this something that is possible to do with ...

I tried using the solution provided in http://stackoverflow.com/questions/1117761/sql-query-to-return-rows-in-random-order to fetch random records in my query. But I have to add NEWID() to the list of ...

I have 3 tables (mysql db) on which I want to do an inner join. The problem is that these tables have common columns. I know I could use aliases to differentiate them (select A.x as Ax, B.x as Bx, C.c ...

I would like to achieve something that probably ends up in some kind of conditional select (MS SQL) but I do not know how to.
I have tried to simplified my problem to the description below:
I have 3 ...

I am attempting to write a query that will be consumed by a SSRS 2012 report. Given a paid invoice, with a certain set of account allocations towards which the money paid towards it must be saved, I ...

I have this database and query:
http://sqlfiddle.com/#!2/b4cf72/116
And I would like to add a column with the average of the exam qualifications. However, I try doing this but it tells me there are ...