If we have a table called FollowUp and has rows [ ID(int) , Value(Money) ]
and we have some rows in it, for example
ID --Value
1------70
2------100
3------150
8------200
20-----250
45-----280
and we want to make one SQL Query that get each row ID,Value and the previous Row Value in which data appear as follow
ID --- Value ...
I am trying to come up with a query to report revenue. It will require 2 tables: clicks and offers. Revenue is calculated by the number of conversions * commission for the offer. Conversions are stored in the clicks table in a field called "conversionDate", and the commission for each offer is stored in the offers table.
There needs ...
so I have an old database that I'm migrating to a new one. The new one has a slightly different but mostly-compatible schema. Additionally, I want to renumber all tables from zero.
Currently I have been using a tool I wrote that manually retrieves the old record, inserts it into the new database, and updates a v2 ID field in the old ...
I see a lot of answers like this one:
Printing a list of persons with more than one home each home with more than one
I have tried that answer with similar models and it seems like a terribly inefficient way of doing this. Each iteration seems to make a separate query sometimes resulting in thousands of queries to a database. I realize...
Does anybody know how to retrieve the values of <ZIPCODE> and <CITY> using PL/SQL? I have followed a tutorial over the net, however, it can retrieve the element names, but not their values. Any of you know what seems to be the problem? I have already consulted Google (the internet's well kept secret) over this but no luck :(
<Zipcodes>...
I try to reuse some columns that I calculate dynamically in Oracle SQL, something like
SELECT
A*2 AS P,
P+5 AS Q
FROM tablename
Where 'tablename' has a column called 'A', but no other colums. This gives me an
ORA-00904: "P": invalid identifier
I know how to work around this by using a subquery like
SELECT P, P+5 AS Q
FROM ...
When you create an index on a column or number of columns in MS SQL Server (I'm using version 2005), you can specify that the index on each column be either ascending or descending. I'm having a hard time understanding why this choice is even here. Using binary sort techniques, wouldn't a lookup be just as fast either way? What differenc...
ActiveRecord objects of the class 'Location' (representing the db-table Locations) have the attributes 'url', 'lat' (latitude) and 'lng' (longitude).
Lat-lng-combinations on this model should be unique. The problem is, that there are a lot of Location-objects in the database having duplicate lat-lng-combinations.
I need help in doing ...
I have a *.aspx page that contains a text box and a button. When the user enters information in to the textbox and clicks post, it inserts the data into my sql database. The issue is, that if the user hits refresh, it will keep inserting the same data into the database. I am pretty sure the whole "click" method is called, not just the in...
I'm working with legacy code here and there are many instances of SQLDataReader that are never closed or disposed. The connection is closed but, I am not sure if it is necessary to manage the reader manually.
Could this cause a slowdown in performance?
...
I have the following UPDATE scenario:
UPDATE destTable d
SET d.test_count = ( SELECT COUNT( employee_id )
FROM sourceTable s
WHERE d.matchCode1 = s.matchCode1 AND
d.matchCode2 = s.matchCode2 AND
d.matchCode3 = s.matchCode3
...
I have a asp:textbox that allows a user to enter information. When the user clicks the asp:button, it inserts the text from the textbox into my sql database, and then redirects back to the page. If the user hits refresh, the event from the button gets called again. I need to rectify this so that it no longer gets called or it doesn't rep...
I want to use naive bayes to classify documents into a relatively large number of classes. I'm looking to confirm whether an mention of an entity name in an article really is that entity, on the basis of whether that article is similar to articles where that entity has been correctly verified.
Say, we find the text "General Motors" in a...
My application (compact framework) works on Windows CE. The "cold boot" of the device resets the systemtime. Is there any way to synchronize systemtime with Windows Server 2003 (IIS) or using a merge replication on SQL Server 2000.
I have a counted column in one of the datatables which counts current time but this row is somehow impossi...
I have a table called auctions, which has various columns such as username, auction id(the primary key), firstname, lastname, location etc, as well as a category column. The category column is blank by default, unless it is filled in for a particular record by a user.
I have made a new users table, which has username and category colum...
Hypothetical example:
I have Cars and Owners. Each Car belongs to one (and only one) Owner at a given time, but ownership may be transferred. Owners may, at any time, own zero or more cars. What I want is to store the historical relationships in a MySQL database such that, given an arbitrary time, I can look up the current assignment...
I've got a seemingly unique issue on just one computer in the company. (had to be my boss's) I've got a program from borland C++ that usese a TSQLConnection. It connects to a local firebird server 2.1.1.17910 running as an application. The other computers work fine.
it will ABSOLUTELY NOT connect on this one lappy (local server) for ANY...
I'm attempting to update a large codebase to properly specify the CultureInfo and/or IFormatProvider when formatting/parsing values. For instance, when parsing a value I get from the user, I pass CultureInfo.CurrentCulture when calling TryParse, and when converting a float to a string for persistence, I pass CultureInfo.InvariantCulture ...
What I am trying to do is find out which fields were updated and record the change to a different table.
DECLARE
@BillNo int,
@column_name varchar(500)
SELECT @BillNo = BillNo FROM INSERTED
DECLARE HistoryMonitorLoop CURSOR FOR
SELECT
column_name
FROM
information_schema.columns
WHERE
...
I've a list of .sql script files to create Stored Procedures which I'm using the Eclipse DTP to develop. Currently to create/update all these Stored Procedures, I've to open & run
one by one from the Data Perspective.
Is there a way to create a batch file that run the scripts along the lines of
run createSP1.sql
run createSP...