Ok I think I'm getting the previous year instead of the previous day, but I need to previous day.
SELECT TO_DATE(TO_CHAR(CURRENT_DATE, 'YYYY-MM-DD'),'YYYY-MM-DD') - 1 FROM Dual
I'm comparing it to a datetime stamp in this format and wish to get all the rows from the previous day.
YYYY-MM-DD HH:MM:SS
So I'm trying something like thi...
I have to come up with a way to get data from a SQL server table given it's month
There's a smalldatetime type field called "date" in the "events" table and a field from it looks like this:
29/01/2003 17:00:00
It should be one among those that appear in the gridview when I select jan/03 in a given DropDownList control in ASP.NET.
Wh...
There is a table of currencies rates in MS SQL Server 2005:
ID | CURR | RATE | DATE
1 | USD | 30 | 01.10.2010
3 | GBP | 45 | 07.10.2010
5 | USD | 31 | 08.10.2010
7 | GBP | 46 | 09.10.2010
9 | USD | 32 | 12.10.2010
11 | GBP | 48 | 03.10.2010
Rate are updated in real time and there are ...
Basically, the question says it all. I need a PL\SQL query that returns a list of dates between two dates such that for 01-JAN-2010 to 20-JAN-2010 I would get 20 rows returned:
the_date
--------
01-JAN-2010
02-JAN-2010
03-JAN-2010
04-JAN-2010
...
20-JAN-2010
...
For example I have type:
CREATE TYPE record AS ( name text, description text, tags text[])
And table:
CREATE TABLE items ( id serial, records record[] )
How can I select all items with records with tags 'test' (without using PL/pgSQL)?
...
public IQueryable<ArticleDisplay> SearchNumberOfArticles(int articleNr, string order)
var result = (
from category in db.ArticleCategories
join article in db.Articles on category.CategoryID equals article.CategoryID
orderby article.Date order
...
Hi folks
Not too sure what's going on here as this doesn't seem like standard practise to me. But basically I have a basic database thingy going on that lets users submit code snippets. They can provide up to 5 tags for their submission.
Now I'm still learning so please forgive me if this is obvious!
Here's the PHP script that makes i...
This should be and easy one for the LINQ gurus out there.
I'm doing a complex Query using UNIONS and CONTAINSTABLE in my database to return ranked results to my application.
I'm getting duplicates in my returned data. This is expected. I'm using CONTAINSTABLE and CONTAINS to get all the results I need. CONTAINSTABLE is ranked by SQL a...
Given the following database structure
I'm trying to write a LINQ query that will return images grouped by tags it's associated with. So far I've got this:
var images = from img in db.Images
join imgTags in db.ImageTags on img.idImage equals imgTags.idImage
join t in db.Tags on imgTags.idTag equals t.idTag
where img.OCRDa...
I have a table called "Event". A column has "duration"--which is...how long that event lasts.
What database type should this be? Integer? (in seconds)?
In the future, I will do statements such as:
If now() > event.duration THEN don't display the event.
...
Hi there,
I'm having trouble with a query in SQL Server 2008 on some forex trading data. I have a trades table and an orders table. A trade needs to comprise of 2 or more orders. DDL schema and sample data below.
What I want to do is write a query that shows the profit/loss in pips for each trade. A pip is 1/1000th of a currency. So th...
I'm a bit confused on this. I have a data table structured like this:
Table: Data
DataID Val
1 Value 1
2 Value 2
3 Value 3
4 Value 4
Then I have another table structured like this:
Table: Table1
Col1 Col2
1 2
3 4
4 3
2 1
Both columns from Table1 point to the data in ...
I am currently designing a forum as a personal project. One of the recurring issues I've come across is database queries in loops. I've managed to avoid doing that so far by using table joins or caching of data in arrays for later use.
Right now though I've come across a situation where I'm not sure how I can write the code in such a w...
I'm storing Points Of Interest (POI) in PostgreSQL database, and retrieve them via PHP script to Android application. To reduce internet usage I want my mobile app to know if there are any points in the neighborhood of currently displayed area.
My idea is to store bounds of the rectangle containing all points already retrieved (in other...
Hello, is there any way how in this situation insert and update DB with single queries?
$message = 'Hello to all group members';
$userdata = mysql_query("SELECT memberid, membernick FROM members WHERE groupid='$cid'") or die('Error');
while(list($memberid, $membernick) = mysql_fetch_row($userdata)) {
$result1 = mysql_query("I...
Hi,
I'm doing query like that:
SomeObject.objects.annotate(something=Avg('something')).order_by(something).all()
Now, I normally have an aggregate field in my model that I use with Django signals to keep in sync, however in this case perfomance isn't an issue so I thought I'd keep it simple and just use subqueries.
This approach, h...
I have a MySQL table containing data on product features:
feature_id feature_product_id feature_finder_id feature_text feature_status_yn
1 1 1 Webcam y
2 1 1 Speakers y
3 1 1 ...
I want to query an IP to get its hostname. What is the standard port for this ? Could it be port 101 listed under "hostnames" in /etc/services ?
...
Hi, what is the best method to insert a search query into MySql
and check for double words? (for showing up the last searches and a collection of searches)
maybe something like this:
< ?php
/*------------------------------
Read and save the search query
-------------------------------*/
$querystat = mysql_real_escape_string($_GET['q'...
Hello all,
Can anyone explain why this query returns an empty result.
SELECT *
FROM (`bookmarks`)
JOIN `tags` ON `tags`.`bookmark_id` = `bookmarks`.`id`
WHERE `tag` = 'clean'
AND `tag` = 'simple'
In my bookmarks table, I have a bookmark with an id of 70 and in my tags table i have two tags 'clean' and 'simple' both that have the colu...