Hi everybody,
I have one model, which I save changes witch happens to certain person. I want to get now the latest state of all person.
so I need to:
- order: created_at asc.
- find_all: limit: one change each person
how can I accomplish that?
Thanks,
Markus
...
I am trying to solve a unique problem. Thanks for any help with this.
Is there an easy way to generate some kind of a hash code for a record based on several of its field values?
I thought about just creating a view with an extra column that concatenates all of the values that I want to check, but I'm checking to see if there is a bet...
In SQL Server 2005, I have a Product search that looks like:
select ProductID, Name, Email
from Product
where Name = @Name
I've been asked to ignore a couple "special" characters in Product.Name, so that a search for "Potatoes" returns "Po-ta-toes" as well as "Potatoes". My first thought is to just do this:
select ProductID, Name, ...
Query -
Select * FROM tbl1
LEFT OUTER JOIN tbl2 ON tbl1.id = tbl2.id
AND tbl2.col2 = 'zyx'
AND tbl2.col3 = 'abc'
WHERE tbl1.col1 = 'pqr'
Here I'm doing left outer join and using 'and' along with join.
(First I was using joins 'and' part in 'where' but my results were not correct)
My q...
i have two tables in sql server -
one with 51 american states, and the other with name,state.
the table with name state has different records namely -
Seere -- AK
Seere -- LA
Seere -- CA
John -- HI
John -- MA
I want a query that picks up one name say "Seere" and shows all the states from state table, and the name attached to those s...
I'm certain I'm overlooking something very basic here but I can't wrap my head around it after querying and googling for about an hour.
I have a datetable already in existence, if that helps. It is populated with this past years' worth of dates and is updated nightly via a stored proc that gets run by a job on the server.
What I need t...
I have a VB6/Access application that occasionally encounters a problem with wrong autonumber field seed.
Lets say there is a table MYTABLE with an autonumber field ID (that is also the primary key). Lets say at the moment the maximum value of ID is 1000. When the application inserts a new record (ID value is not provided explicitly), f...
Oracle 10g.
We have a large table partitioned by a varchar2 column (if it were up to me, it wouldn't be this column, but it is) with each partition having a single value. Ex. PARTITION "PARTION1" VALUES ('C').
We also have NLS_COMP = LINGUISTIC.
Partition pruning, when indicating a value in that column, doesn't work.
SELECT * from ...
Can someone tell me what is the difference between these two:
ALTER TABLE x1 ADD INDEX(a);
ALTER TABLE x1 ADD INDEX(b);
AND
ALTER TABLE x1 ADD INDEX(a,b);
I know this goes down to the very basics but sometimes I find the former seems to be a little faster than the latter. Is it just my feeling or is there some actual reason for it?...
I'm trying to optimize some slow web pages, and my guess is that the problem has to do with SQL blocking (doesn't seem to be a matter of CPU or I/O utilization on the web server or database server). What's the quickest way to find out what queries are getting blocked and what queries are doing the blocking?
...
I have a table and am debating between 2 different ways to store information. It has a structure like so
int id
int FK_id
varchar(50) info1
varchar(50) info2
varchar(50) info3
int forTable or char(3) forTable
The FK_id can be a foreign key to one of 6 tables so I need another field to determine which ...
I got a table with some time data in the format of yyyymmddMilliseconds. For example, 20100218000051234. How to convert this into DateTime type? In SQL Server 2008.
...
What is the correct syntax to perform an outer join with the following requirements:
A left outer join B on A.c1 = B.c1
B left outer join C on B.c2 = C.c2
A left outer join D on A.c1 = D.c1
So A, B, and C cascade and A and D cascade.
I know how to write the A->B->C but I don't know how to add D. I need scope or parenthesis or someth...
Any recommendations for a module which keeps SQL queries external to the application, for Ruby programs? I'm looking to avoid hardcoding SQL queries and possibly to support multiple SQL backends in a set of programs that make direct SQL queries (that is, not mediated via an ORM).
Hyopthetically:
# Production system is pg, dev environm...
I have a a form:
<form id="deletesubmit" style="display:inline" >
<input style="width:50px" type="text" id="delcustomerid" name="delcustomerid" value="'.$row['customersid'].'">
<button type="submit" class="table-button ui-state-default ui-corner-all" title="delete"><span class="ui-icon ui-icon-trash"></spa...
I am creating a ETL process in MS SQL Server and I would like to have errors specific to a particular column of a particular row. For example, the data is initially loaded from excel files into a table(we'll call the Initial table) where all columns are varchar(2000) and then I stage the data to another table(the DataTypedTable) that co...
I have the following tables in MySQL server:
Companies:
- UID (unique)
- NAME
- other relevant data
Offices:
- UID (unique)
- CompanyID
- ExternalID
- other data
Employees:
- UID (unique)
- OfficeID
- ExternalID
- other data
In each one of them the UID is unique identifier, created by the database.
There are foreign keys to ensure ...
This is in regards to MS SQL Server 2005.
I have an SSIS package that validates data between two different data sources. If it finds differences it builds and executes a SQL update script to fix the problem. The SQL Update script runs at the end of the package after all differences are found.
I'm wondering if it is necessary or a good ...
I've heard that you should put columns that will be the most selective at the beginning of the index declaration. Example:
CREATE NONCLUSTERED INDEX MyINDX on Table1
(
MostSelective,
SecondMost,
Least
)
First off, is what I'm saying correct? If so, am i likely to see large differences in performance by rearranging the order...
here is my table description:
Table Name : Orders
Columns : ID, NO, Quantity, Base, Code
First my query should check the value of Code, if value of Code is 'B' then OUTPUT VALUE should be Code+Base if it is not 'B' then OUTPUT VALUE should be Code+Quantity
the obtained rows again will be filtered by using where clause where ID='' ...