I have this table view
UserName Product NumberPurchaces
-------- ------- ---------------
'John Doe' 'Chair' 4
'John Doe' 'Table' 1
'Jane Doe' 'Table' 2
'Jane Doe' 'Bed' 1
How can I create a query that will provide this pivot view in Oracle 10g ?
UserName Chair Table Bed
--------...
I have a system where reservations are stored as records in one table(workshop_reservation) and sessions (the things being reserved) are stored in another table(session). Each reservation belongs to a session, and each session belongs to a workshop.
I want to make a mysql query that finds the number of reservations for each session that...
I've got a table like this:
ID | Val1 | Val2
---------------------
1 | 1 | 2
2 | 1 | 3
3 | 2 | 1
4 | 2 | 3
5 | 3 | 1
6 | 3 | 2
now my problem is, that 1 - 2 means the same like 2 - 1 (look @ ID 1 and ID 3 for example) and I want to eliminate all entries where value 1 - value 2 ...
Hi guys I know that this is really bad idea but I want join three tables for my query on polymorphic association
for example
class Article
has_many :comments, :as=>:commentable
end
class Post
has_many :comments, :as=>:commentable
end
class Comment
belongs_to :commentable, :polymorphic=>:true
end
and I need to get something s...
Simple question (I hope):
I have a simple two column table, a measurement and the time the measurement was taken.
How can I select all of the measurements taken at 30 minutes past the hour? Although these measurements are supposed to be made at a regular interval (every 15 minutes in this case), there are often gaps in the data.
Sampl...
Hi all,
I was wondering what would be a good way to accomplish the following using mysql:
Lets say I have a table that contains these fields:
MyTable
---------
Country [string]
Region/Province/State [string]
City [string]
And I have the following data rows in the database
Entry 1: Canada, Ontario, Toronto
Entry 2: Canada, Ontario,...
hi everyione, i'm getting wrong result of query in group function , i'm using 3 tables
1. sale with columns AccointId,NetAmount , quantity, date
2. Purchase colums AccounId,NetAmount,quantity,date
3.Account colums AccountId,AccountName
i made a stored procedure that take two input like Date1,Date2
i'm required that Account.AccountName...
Choosing carefuly datatypes, finally a complex Class is created,
then using a HashMap, those first Class objects get mapped with a key.
and now I can create thousands and access them, add, delete, etc..
Now if I want to store them in a DB..
So I start from scratch? have to create the table?, again take care about datatypes?
to make fit...
Let's say I have a table like this called hours:
employee, payperiod, hours
greg, 1/31/2010, 12
greg, 1/31/2010, 15
mark, 1/31/2010, 10
mark, 1/31/2010, 11
greg, 2/28/2010, 12
greg, 2/28/2010, 15
greg, 2/28/2010, 4
How would I find the year to date hours for a given employee and payperiod?
For the above example I'd want to get to:
e...
I have written a code to add user into DB. I need to redirect to EmpInfo.jsp, when we receive duplicate entries. I need to use more Exceptions for that and also i want to know how to redirect.
response.setContentType("text/html");
PrintWriter out = response.getWriter();
Connection conn = null;
String url = "jdbc:mysql:/...
I have a table, with the following columns:
PK1 PK2 ID DATE Value flag
I do a calculation that involves taking the max value per ID.
select id,
max(value)
from table
group by id
I want to mark the flag on the rows that I am using. If id and the max(value) correspond to multiple rows flag the one with the...
Maybe this is a dumb question, but I don't know the answer. If I use MySQL Connector/Net, when I send SQL via ADO.NET, does my inline SQL get translated into code first and then sent to the database, or does it get sent as SQL text, and then the database engine has to translate it into code?
Or doesn't ADO.NET do a translation?
Or, if...
I've sublassed QSqlRelationalTableModel for one of the tables in my app. Basically I've added custom header data and custom flags so some columns are non-editable. Also a custom setData() function to reject null primary keys. The table's edit strategy is QSqlTableModel::OnRowChange. My app has a button that inserts a new row when pressed...
I'm trying to write a query in Oracle SQL to access a particular substring in a CLOB field.
To use the SUBSTR function, I need to come up with a starting point in the CLOB using the INSTR function.
The CLOB contains X12 data that is delimited with hexadecimal characters.
To find the starting offset for my substring, I'd like to do som...
This should be a softball for you SQL guys. I know I can add to an int field with something like "UPDATE tblUser SET Total=(Total+2)" but what is the syntax for adding seconds to a datetime field?
I'm using SQLServer 2008
...
can you make pivot/unpivot in mysql similar to ms sql server?
thanks
Here's a link to how SQL Pivot works: link text
...
I'm not very good at SQL, but I'm certainly learning.
So this one provides content for a couple of lists below wordpress posts. One is, "More popular articles from this user," and the other is "More popular articles in this category."
Articles can be published by editors, or submitted by logged in or anonymous users.
It just checks all...
I need to do a lot of processing on a table that has 26+ million rows:
Determine correct size of each column based on said column's data
Identify and remove duplicate rows.
Create a primary key (auto incrementing id)
Create a natural key (unique constraint)
Add and remove columns
Please list your tips on how to speed this process up ...
I currently have a database schema that contains a user's password in plain text. I've added a new column called password of type binary(16) with the intent of hashing the current plain text password via MD5. When I do this, I'm finding that the value stored in the password field is wrong. Here's my conversion query:
UPDATE my_table ...