sql

Data Aggregation in SQL Server 2005

I need a query for SQl server 2005 (SQL server management studio express). I have data stored as 1 minute time frame (1 minute each row), for each table columns are ID, Symbol, DateTime, Open, High, Low, Close, Volume. I need to convert (compress) to every possibile multiple time frame, so let's say 10 minutes, 13, 15, and so on. Provid...

Is that possible and safe to add ENUM value to SQL database column type ?

I have an application that works with database (PHP + MySQL). One of the columns in the database table is of type ENUM('VALUE1','VALUE2'). Is that possible to add safely VALUE3 to the ENUM without damaging the data in the table ? ...

pick next 24 hours job

retrieve next 24 hours details from the table i read one thread, same question here link text but small diff is , my field name is jdate is the varachar, but they are used the datetime data type format, ...

SQL distinct or group by

My brain aint functioning atm.. Can you pls help me out here: Got a table with date, analyseid, groupid I want to get unique groupid's.. perhaps with a count on same groupid's. Also if there are rows with same groupid the date is also the same. SELECT date, analyseid, COUNT(*) AS 'amount', groupid FROM myTable GROUP BY gr...

recursive CTE - limited numbers of rows

Hi I'm trying to create a query on a very simple table (organisations) I have the columns Organisation, Manager, Superior_Organisation CEO Leadership Team, David, CEO Production Management, Alex, Leadership Team Production Site 1, Francoise, Production Management Production Site 2, Steve, Production Management Production Site 1 Maint...

Browse a SQL-Dump file without importing it into a DBMS?

Is somebody aware of a tool that lets me browse MySQL-Files without having to import them into my database system? I'm looking for an easy way to inspect MySQL Backups quickly without having to import them - but still being nicely displayed, so viewing the SQL source is not really an option. Maybe there's a program that takes the SQL du...

Create date from day, month, year fields in MySQL

Hello, I am currently developing an application that displays documents and allows the members to search for these documents by a number of different parameters, one of them being date range. The problem I am having is that the database schema was not developed by myself and the creator of the database has created a 'date' table with f...

Can a COMMIT statement (in SQL) ever fail? How?

When working with database transactions, what are the possible conditions (if any) that would cause the final COMMIT statement in a transaction to fail, presuming that all statements within the transaction already executed without issue? For example... let's say you have some two-phase or three-phase commit protocol where you do a bun...

TSQL, Ordering of ORDER BY.

Given a table of Name Age Bob 30 Paul 35 John 35 and a statement select * from table ORDER BY Age DESC What is the ordering of the resulting table? Name Age Paul 35 John 35 Bob 30 or Name Age John 35 Paul 35 Bob 30 or undefined behaviour? ...

MySQL: How to calculate weeks out from a specific date?

I need to calculate the weeks out from a date in my MySQL select statement. There is a date column in one of the tables, and I need to calculate how many weeks away the date is. SELECT EventDate, (calculation) AS WeeksOut FROM Events; Example: 6 days away, weeks out = 0 7 days away, weeks out = 1 13 days away, weeks out = 1 14 days ...

WHERE and JOIN order of operation

My question is similar to this http://stackoverflow.com/questions/879893/sql-order-of-operations but with a little twist, so I think it's fair to ask. I'm using Teradata. And I have 2 tables: table1, table2. table1 has only an id column. table2 has the following columns: id, val I might be wrong but I think these two statements give...

query not working with empty fields on access

What is wrong in this query running on MS Access 2003 database. It works fine if fields are not empty, but when any of the fields is empty it results empty string. SELECT CustomerName,IIF(Address1="","",Address1)+IIF(Address1& Address2="","",",")+IIF(Address2="","",Address2)+IIF(Address1&Address2& Address3="","",",")+IIF(Address3=" ","...

How do you merge tags on an already existing system

We have a simple interface to tag a particular question (e.g. entry has 1..many tags and each tag entry has a foriegn key pointer back to the entry table) 1. What is the current production version of the jdk? (Tags: jdk6 jdk-6 jdk java) 2. In what version was java.util.spi package introduced? (Tags: jdk-6, jdk7, jdk5) 3. Whic...

multiple access to sql server database, one table

I have multiple apps running which access a sql server database. I had initially a table set aside for each app but now I was told to put everything into one table and have all apps access the database. I just want to make sure that just changing my connection string for all apps will suffice and that I do not have to make any other chan...

SQL Server table perf comparison -- temp tables, or table variables? Or something else?

In SQL Server, I'm trying to do a comparative analysis between two different table structures with regard to insert performance given different keys. Does it matter if I use a table variable to do this testing, or should I use a temporary table? Or do I need to go to the trouble of actually creating the tables and indexes? Specificall...

SQL Server TSQL Debugging - Massive View - Any Tips?

Hi, I've been asked to debug a view that's producing split rows where they should be grouping. In trying to debug, I'm trying testing all of the joined sub tables in isolation. The thing is, there's so many dependancies (11 joins in all), that once you get all of the dependencies required to run the query, you basically have the origina...

How can I pass a list of pairs to an Oracle stored procedure?

I want to write an Oracle PL/SQL stored procedure that takes as a parameter a list of pairs of some other type, say varchar2(32). Is this possible? What's the best way to do it? ...

How can I find matches in two SQL tables?

I have two tables, UsersSample and UsersSearching. UsersMain is a table of the majority of available users. UsersSearching is a table of any users who have searched on the site. I am trying to determine if a user from USersSample has searched (and appears in the UsersSearching table). But I'm having difficulty even beginning this S...

iPhone - Save and download user comments to and from the internet

I have a photogallery in my app that I want users to be able to comment on, adding funny captions, and I want users to be able to click Thumbs Up or Thumbs Down. What is the best way to store and load the comments and thumbsup/down information? I'm a bit of a noob to the iOs and am assuming I would have my own website hosting a mysql d...

Apply the unique constraint to combinations of columns in SQL

Hi, I have a table called product_attributes in a MySQL Database. It consists of a product SKU (foreign key), an attribute label and an attribute value. I need to ensure that combinations of SKU and attribute labels are unique. EXAMPLE - inserting this would be legal {001, 'weight', '100 lbs'} {001, 'color', 'blue'} {002, 'weight'...