I am wanting to do some queries on a sales table and a purchases table, things like showing the total costs, or total sales of a particular item etc.
Both of these tables also have a date field, which stores dates in sortable format(just the default I suppose?)
I am wondering how I would do things with this date field as part of my que...
Hi,
Given the following table format...
id | date | value
___|____________|______
11 | 2010-01-01 | 50
11 | 2010-01-02 | 100
12 | 2010-01-01 | 150
12 | 2010-01-02 | 200
... I need to select the id that corresponds to the maximum value on a day that I specify. The only way I've figured out how to do this so far is using a sub-qu...
It seems that all questions regarding this topic are very specific, and while I value specific examples, I'm interested in the basics of SQL optimization. I am very comfortable working in SQL, and have a background in hardware/low level software.
What I want is the tools both tangible software, and a method to look at the mysql databas...
Hi
I was playing around with a stored procedure and I think I made an endless while loop(I think I forgot to close the cursor)
now it is sending me emails and I don't know how to stop it. How can I kill it?
edit this is what I see when I do what remus told me to do
Sorry I don't know how to output the results nicer.
1,0,2010-07-06 1...
I'm trying to change all the NULLs in an INT column to an incrementing value using a statement like this:
UPDATE [TableName] SET [ColumnName] = dbo.FunctionName() WHERE [ColumnName] IS NULL
where the function looks like this:
CREATE FUNCTION FunctionName() RETURNS INT AS
BEGIN
RETURN (select MAX(ColumnName) + 1 from TableName)
EN...
Hi, sorry about the question I am a newbie to sql. i am attempting to create a search query for our database and I was wondering how would you filter certain words from your query for example:
Here is the sample data (the name column): Jean, Jain, Joan, Jorn, Juan, John, Juin
Lets say that we are searching for the names that start with...
hi there
i have two queries, querying the same table, but based on different parameters,
i then need to mush these two result sets together based on certian parameters
//get initial text
Q1
SELECT
campaign_id AS campaign_id,
from_number AS mobile,
received_msg AS join_txt,
date_received AS join_txt_date
FROM received_txts WHERE act...
I am trying to do some operation in column 'Increment' based on previous row record in column 'Value'
e.g.
row_num| Period | Measure | Decay
1 | Jan 08 | 10 |
2 | Feb 08 | 18 |
3 | Mar 08 | 7 |
4 | Apr 08 | 67 |
i would like to update column 'Decay' based on a formula
row_num| Period | M...
I have two tables, sales and costs, each with a costs fields, and a date field of type date.
The rest of the fields are not relevant for what I want to do.
I want to take the totals of each month, and display them together.
I am unsure if most of this should be done in SQL, if it must be one or several queries, of if I must manipulate...
Does update_attributes protect against sql injection?
Example:
if @user.update_attributes(params[:user])
# updated
end
I know find(), and {} and [] do in find :conditions, but didn't see any info on this method.
...
Does ModelName.new protect against sql injection?
Example:
@user = User.new(params[:user])
@user.save
I've read the rails security docs and didn't see anything about inserts via Model.new.
Thanks!
...
I have a products table, with the fields productname, category and cost, of type varchar, varchar and double.
I then have a sales table, with the fields productname, cost, and saledate, of type varchar, double and date.
Lastly, I have a purchases table with the fields purchase, cost and purchasedate, of type varchar, double and date.
...
Does build protect against sql injection?
Example:
@post = @user.posts.build(params[:post])
@post.save
Didn't see build in the rails security docs.
Thanks!
...
I have a products table, with the fields product, category and cost, of type varchar, varchar and decimal.
I then have a sales table, with the fields client, productname, quantity, cost, and saledate, of type varchar, varchar, int, decimal and date.
I want to show all of the products sold for a month, say the current month.
However, I...
I want to create an sql script that can recreate a DB that I already have. I want to recreate the DB without data inside.
So is there anyway with sqlplus of exporting a DB of a user?
...
hello everyone
i have table a follows
userid answer
1 true
1 true
1 false
1 true
1 true
1 true
2 true
1 true
i want to get the latest count of true sequence per user
so i will get
userid count
1 4
2 1
please help
...
let say i do select score from table1. this will return result
score
----
0
20
40
how to use case, to change the output to if 0->strongly not agree 20->agree 40->very agreed
...
Hey guys
I have a complex SQL Query, that needs to be filtered further. Part of the WHERE clause looks like this:
Where P.PeriodID in (36, 37)
I need to get it to look more like this:
Where P.PeriodID in dbo.GetPeriodsInRange(@startDate, @endDate)
The function must return a list of PeriodIDs to be used by the IN statement. I reall...
I have three tables products, sales and costs.
The sales and products table each have a costs field of type decimal and a date field of type date.
Additionally, the sales table has a productname field, which is matched to a productname field in the products tables.
The products table also has a category field.
I want to select all sa...
Referring to a previous question, i was wondering if its always possible to replace DECODE by CASE and which one is better for performance?
...