You cannot (should not) put non-aggregates in the SELECT line of a GROUP BY query.
I would however like access the one of the non-aggregates associated with the max. In plain english, I want a table with the oldest id of each kind.
CREATE TABLE stuff (
id int,
kind int,
age int
);
This query gives me the information I'm aft...
I have some table that have an identity column that I am trying to reseed. The reseeding works (I think) but when a new data item is inserted into the table the identity column starts at 0.
My code to reseed is:
DBCC CHECKIDENT(MyTable, RESEED, 0)
The Identity Specifications for the tables are:
Identity Increment = 1
Identity Seed =...
I want to write a stored procedure that works something like this:
SELECT * from T where T.A = @a and T.B = @b
if that returns rows, return those rows, if not, return
SELECT * from T where T.A = @a and T.B IS NULL
Edit:
It feels that there should be a way to create a procedure such that it runs the first query once and runs the se...
I have column OFF_SAT_COMP.LINKACCT and OFF_SAT_COMP.COUNTRY. I am trying to add the values of these two columns in a given row together, but when I do so as follows:
(OFF_SAT_COMP.LINKACCT + OFF_SAT_COMP.COUNTRY)
It is concatenating rather than returning the sum of the two column values. e.g. It is returning 500300 where I want 800. ...
How do I specify a date range in MS Access? Is the below query correct? Do I have to put "2/1/2010" in quotes? Or do I have to do something like date(2/1/2010)?
SELECT [Occurrence Number] as Fld
FROM [Lab Occurrence Form]
WHERE [Practice Code]="ACCIM"
AND [1 0 Preanalytical (Before Testing)]="1.1 Specimen Mislabeled"
AND ([Occu...
My company is working on a development project using SQL Server 2008 Express. The amount of data we plan to store in our main table will quickly exceed the 4GB size limit of Express. We can buy ourselves some time with SQL Server 2008 R2, but eventually we will surpass the 10GB limitation as well.
The team lead wants to hear all availab...
Hey everybody, got an interesting question I think. I've got a Silverlight3 application which is querying a SQL Server 2005 database asynchronously. However, some of the data sets the queries return are massive and so I'm looking into data pagination.
Goals:
1) Just in time data calls - I only want to query for page 3's data when the ...
I have a table in a MySQL table with a fieldname 'product', and want to rename it to 'ds-product'.
The CMS type system I am using uses the id of formfields as the name of the table field to insert into.
For most this works fine, but for a particular field it prepends 'ds-' to whatever ID I give it, so I must make the table field name m...
I am writing a SQL Stored Proc which takes in a single table valued parameter. Is it possible for me to create the table type in the parameter definition, for example:
CREATE PROCEDURE example (
@param (CREATE TYPE tableparameter ( column1 int, colunn2 varchar.... )) READONLY
)
...
I have the following query. What is strange is that it is returning multiple records for the same individual - but it should be returning just one row for each individual. It is all LEFT JOINS based on CONTACT1 C - which has only one row for each individual, unlike the other columns which sometimes have multiple rows for the same individ...
I uploaded a csv file to MySQL DB but for some reason data from two columns got glued to one.
e.g. the data 0880174V,D should have gone to two different columns.
Is there a way (via sql) i can split the data from this column (i.e. as 0880174V and D) and update the table, without having to delete the record and re-upload? I have a milli...
I have tables FOO and BAR. FOO has a foreign key to BAR's PK.
When I execute the following query it takes several seconds.
select foo.name, foo.description, bar.quadrant from FOO, BAR
where FOO.BAR_ID = BAR.BAR_ID
Here is my explain plan:
OPERATION OBJECT_NAME OPTIONS COST
SELECT STATEMENT ...
I am looking at creating an application to record gym workout(set,reps, etc) and I was wondering what framework and database backend to use. I am currently thinking C# .Net 3.5 for the framework because I am familiar with it but I'm unsure about how to store the data. Originally I was thinking of xml files and parsing through them but th...
I have three tables, we'll call them table1, table2, and table3. Lets say each table has a user id column and a date column. What i'd like to do is to be able to count the number of rows with a specific user id in table1, and sum it with the number of rows with that user id in tables 2 and 3.
I'd then like to take that first query I d...
I have a stored procedure which I edit through Visual Studio 2008. Is there a simple way to change the name of the stored procedure? Right now if I look at the sproc's properties, the name of the sproc is grayed out.
...
I have my database built already, but I really want to print out an erd to reference while I'm building my models. Is there a utility that can generate an erd from a SQL dump or by connecting to the database directly?
Thanks in advance,
~Brandon
...
How can one trigger an event locally when a field in a connected database changes? I've done some research but it seems like there there are varying and inconclusive answers to the question.
I'm building an application where users rate comments, and I'd like to have the ratings change live when they are modified by a different user. For...
I have a table User with a bunch of indexes. One of them is a unique index on the AccountIdentifier column.
Since this is a unique index, why is a key lookup required in addition to the index seek? The index seek tooltip reports that only one record is returned. I've also tried converting the index to a "unique key" type.
...
Hi, i want select similar rows accourding to row's title columun. Title columun has mostly have 5 or 6 six keywords. Which algorithm do you recommend ? Soundex Maybe ?
P.S: Title columun has unicode chracters like Ç, Ö, Ş...
...
Hello,
I have a view which combines two tables via UNION ALL. The view is also schemabound, if that matters (WITH SCHEMABINDING).
Is it possible to enable fulltext search on this view? I understand that Fulltext Search requires a unique index, but I can't create it because of UNION.
Is there another way to make Fulltext Search work on...