sql

Eliminate subquery for average numeric value

Quest The query selects all the points beginning with "Vancouver" and are within a 5 minute area from the center of all locations beginning with "Vancouver". For example, Vancouver South Fraser, Vancouver Fairview, and Vancouver Ballantree Place W have latitudes and longitudes within 5 minutes of their average latitude and longitude. Th...

Write a sql to get the last data

Hello everyone, I have a Realtime table with example data: Symbol Date Value ABC 1/3/2009 03:05:01 327 -- is last data for 'ABC' ABC 1/2/2009 03:05:01 326 ABC 1/2/2009 02:05:01 323 ABC 1/2/2009 01:05:01 313 BBC 1/3/2009 03:05:01 458 -- is last data for 'BBC' BBC 1/2/2009 03:05:01 ...

Getting the most recent entry per group in a select statement

I have 3 tables to join to get table1.code, table1.series, table2.entry_date, table3.title1 and I'm trying to get the most recent non null table3.title1 grouped by table1.code and table1.series. select table1.code, table1.series, max(table2.entry_date), table3.Title1 from table3 INNER JOIN table2 ON table3.ID = table2....

How to add data to sql but for one id and more than one data ?

i have one id and more filepaths.forexample: id:123456 FilePath: C:/a.jpg C:/b.jpg C:/c.jpg C:/d.jpg C:/e.jpg Result must be: 123456|C:/a.jpg 123456|C:/b.jpg 123456|C:/c.jpg 123456|C:/d.jpg 123456|C:/e.jpg How can i add more than one path for one id But My result is : 123456|C:/e.jpg i need others public bool AddDCMPath2(...

SQL JOIN with two or more tables as output - most efficient way?

I have an SQL query that executes a LEFT JOIN on another table, then outputs all results that could be coupled into a designated table. I then have a second SQL query that executes the LEFT JOIN again, then outputs the results that could not be coupled to a designated table. In code, this is something like: INSERT INTO coupledrecords SE...

WM_CONCAT use CASE

I have a select: select substr(acc,1,4) ,currency , amount , module , count(*) , wm_concat(trn_ref_no) trn from all_entries where date = to_date ('01012010','DDMMYYYY') group by substr(acc,1,4),currency, amount, module In this case I get an error: ORA-06502: PL/SQL: : character string buffer too ...

alphanumeric and special character sorting

Hi ppl, I wanted to know the different standards of sorting. To be more specific take the sample set: (Please note there's capitals, small letters, special characters, null values and numbers here) A a 3F Zx - 1Ad NULL How would the Oracle Database sort this by default? How would LINQ sort this by default? How would db2 sort this...

how to write this query using joins?

Hi, i have a table campaign which has details of campaign mails sent. campaign_table: campaign_id campaign_name flag 1 test1 1 2 test2 1 3 test3 0 another table campaign activity which has details of campa...

again new query. i am trying to solve this from one hour. please help

Query : List the film title and the leading actor for all of 'Julie Andrews' films. there are three tables movie (id, title, yr, score, votes, director) actor (id, name) casting (movieid, actorid, ord) select movie.title,actor.name as cont from movie join casting on (movie.id=casting.movieid) join actor on (casting.acto...

Create a trigger in sql server 2008

Hi, I am trying to create a trigger for a cinema database. I need it to update once a rating is added for a movie showing the text "rating added". The table name is movie_ratings the primary key is = movie_rating I am not really sure how to do it, I have looked online but still are not too sure. I was wondering if anyone could help. ...

jQuery - Save to SQL via PHP

This is probably easy for you guys, but I can't understand it. I want to save the filename of an image to it's own row in the SQL base. Basically, I log on to the site where I have my own userID. And each user has its own column for background images. And the user can choose his own image if he wants to. So basically, when the user cli...

How to create window service to read the xml file

hi, i have to create window service which read the xml file and and take the node's value to connect the sql server and create the log file i have already created window application for that but i don't know how to create win services. ...

SQL Server 2008 - Query takes forever to finish even though work is actually done

Running the following simple query in SSMS: UPDATE tblEntityAddress SET strPostCode= REPLACE(strPostCode,' ','') The update to the data (at least in memory) is complete in under a minute. I verified this by performing another query with transaction isolation level read uncommitted. The update query, however, continues to run for anot...

how to take the year using date stored in DataBase:

how to take the year using date stored in DataBase: in Sql query ?? ???? eg date stored as 2010-04-29 15:53:09.577 how to get the year in stored procedure to check whether the year i pass and the year stored in database are same ...

Implementing search functionality with multiple optional parameters against database table.

Hello, I would like to check if there is a preferred design pattern for implementing search functionality with multiple optional parameters against database table where the access to the database should be only via stored procedures. The targeted platform is .Net with SQL 2005, 2008 backend, but I think this is pretty generic problem. ...

SQL Statement to update the date

I have a string 1993-08-02 00:00:00.0 and I would like to update the date field in a Access Table This is what I have but it is not working. UPDATE [Table] SET `Birthdate` = '1993-08-02 00:00:00.0' WHERE `ID` = 000 ...

Is there limit of "join" or the "where" or length of SQL query ?

Actually i was trying to get data from elgg database based on multiple joins. It generated very big query with lots of JOIN statements and query never respond back. SELECT distinct e.* from test_entities e JOIN test_metadata m1 on e.guid = m1.entity_guid JOIN test_metastrings ms1 on ms1.id = m1.name_id JOIN test_metastrings mv1 on mv...

Concat not work phpmyadmin (mysql)

hello, i want update my row and concat my string but i have an error with this query UPDATE FILE SET NOMFIC ='supp_'+D_NOMFIC WHERE IdFile = 2 ...

Optimal way to convert to date

I have legacy system where all date fields are maintained in YMD format. Example: 20101123 this is date: 11/23/2010 I'm looking for most optimal way to convert from number to date field. Here is what I came up with: declare @ymd int set @ymd = 20101122 select @ymd, convert(datetime, cast(@ymd as varchar(100)), 112) This is prett...

SQL Server COLLATION on table name

For a SQL Server database with collation set to "Latin1_General_100_CS_AS" I want to run a query like: SELECT * FROM tableName, only the table name in the database is called TableName. SELECT * FROM TableName works fine SELECT * FROM tableName gives error: Msg 208, Level 16, State 1, Line 1 Invalid object name How can I make...