Hi,
I want to sort Grid View on the basis of paticular column.
For example:
Now i want to sort above table in such a way that all Developers should come first.
Thanx
Select
id,
sum(amount),
vat
From transactions WHERE id=1;
Each record in this table has a vat percentage, I need to get the total amount in all records, however each amount has to be multiplied by by its vat %.
Is there away to do this without looping through all records?
I have a table which has an Id and a name field. I usually bind the name to the dropdownlist but I was told that any dml should be on the Id so how can I use the name in the dropdownlist and at the same time still use the Id?
Hi,
If I have a table
AgentID | IsNew | TeamID
1 N 1
2 Y 2
3 Y 2
4 N 2
5 Y 1
I want to return the following from a query:
Team | CountIsNew = N | CountIsNew = Y
1 1 1
2 1 2
Is there a way I can do this?
Using Oracle 10
I have database with oracle number type. Could there any possible issues with using java Double when updating table with numeric column. Should i switch BigDecimal or Double is approriate type.
As I fas as I know, BigDecimal is used when arbitrary precision required, when deal with prices for example.
Consider simple API updatePrice(Double d) Should i persist double as is or BigDecimal.valueOf(d) is preferable ?
I can have a table and function defined as:
CREATE TABLE mytable
(
mycol integer
);
INSERT INTO mytable VALUES (1);
CREATE OR REPLACE FUNCTION myfunction (l_myvar integer) RETURNS mytable AS $$
DECLARE
l_myrow mytable;
BEGIN
SELECT *
INTO l_myrow
FROM mytable
WHERE mycol = l_myvar;
RETURN l_myrow;
END;
$$ LANGUAGE plpgsql;
In this case l_myvar acts as a bind variable for the value passed when I call:
SELECT * FROM myfunction(1);
and returns the row where mycol = 1
If I redefine the function as:
CREATE OR REPLACE FUNCTION myfunction (l_myvar integer) RETURNS mytable AS $$
DECLARE
l_myrow mytable;
BEGIN
SELECT *
INTO l_myrow
FROM mytable
WHERE mycol IN (l_myvar);
RETURN l_myrow;
END;
$$ LANGUAGE plpgsql;
SELECT * FROM myfunction(1);
still returns the row where mycol = 1
However, if I now change the function definition to allow me to pass an integer array and try to this array in the IN clause, I get an error:
CREATE OR REPLACE FUNCTION myfunction (l_myvar integer[]) RETURNS mytable AS $$
DECLARE
l_myrow mytable;
BEGIN
SELECT *
INTO l_myrow
FROM mytable
WHERE mycol IN (array_to_string(l_myvar, ','));
RETURN l_myrow;
END;
$$ LANGUAGE plpgsql;
Analysis reveals that although:
SELECT array_to_string(ARRAY[1, 2], ',');
returns 1,2 as expected
SELECT * FROM myfunction(ARRAY[1, 2]);
returns the error
operator does not exist: integer = text
at the line:
WHERE mycol IN (array_to_string(l_myvar, ','));
If I execute:
SELECT *
FROM mytable
WHERE mycol IN (1,2);
I get the expected result.
Given that array_to_string(l_myvar, ',') evaluates to 1,2 as shown, why arent these statements equivalent.
From the error message it is something to do with datatypes, but doesnt the IN(variable) construct appear to be behaving differently from the = variable construct?
What are the rules here?
I know that I could build a statement to EXECUTE, treating everything as a string, to achieve what I want to do, so I am not looking for that as a solution. I do want to understand though what is going on in this example. Is there a modification to this approach to make it work, the particular example being to pass in an array of values to build a dynamic IN clause without resorting to EXECUTE?
Thanks in advance
Craig
With the recent announcement of .NET 4.0 and Visual Studio 2010, it is becoming ever more difficult to keep track of what .NET Framework versions build on what version of the CLR and belong with which version(s) of Visual Studio.
Is there a definative table that shows these relationships?
I have just installed paperclip into my ruby on rails blog application. Everything is working great...too great. I am trying to figure out how to tell paperclip not to output anything if there is no record in the table so that I don't have broken image links everywhere. How, and where, do I do this?
Here is my code:
class Post < ActiveRecord::Base
has_attached_file :photo, :styles => { :small => "150x150"}
validates_presence_of :body, :title
has_many :comments, :dependent => :destroy
has_many :tags, :dependent => :destroy
has_many :ugtags, :dependent => :destroy
has_many :votes, :dependent => :destroy
belongs_to :user
after_create :self_vote
def self_vote
# I am assuming you have a user_id field in `posts` and `votes` table.
self.votes.create(:user => self.user)
end
cattr_reader :per_page
@@per_page = 10
end
View
<% div_for post do %>
<div id="post-wrapper">
<div id="post-photo">
<%= image_tag post.photo.url(:small) %>
</div>
<h2><%= link_to_unless_current h(post.title), post %></h2>
<div class="light-color">
<i>Posted <%= time_ago_in_words(post.created_at) %></i> ago
</div>
<%= simple_format truncate(post.body, :length => 600) %>
<div id="post-options">
<%= link_to "Read More >>", post %> |
<%= link_to "Comments (#{post.comments.count})", post %> |
<%= link_to "Strings (#{post.tags.count})", post %> |
<%= link_to "Contributions (#{post.ugtags.count})", post %> |
<%= link_to "Likes (#{post.votes.count})", post %>
</div>
</div>
<% end %>
There's a table like this one
______________________
| id | title | order |
|----------------------|
| 1 | test1 | 1 |
|-----|--------|-------|
| 2 | test2 | 2 |
|-----|--------|-------|
| 3 | test3 | 3 |
|-----|--------|-------|
| 4 | test4 | 4 |
'----------------------'
when i introduce in my mysql shell a single update to a row
$sql UPDATE `table` SET order=1 WHERE id=3;
And then procedure or method resamples order column in the before update lower values to get its order renewed like this
______________________
| id | title | order |
|----------------------|
| 1 | test1 | 2 |
|-----|--------|-------|
| 2 | test2 | 3 |
|-----|--------|-------|
| 3 | test3 | 1 |
|-----|--------|-------|
| 4 | test4 | 4 |
'----------------------'
Any help would be appreciated, thanks!
Hi,
I have a specific DB2 query, and I would like to execute this query using criteria.
The query:
SELECT
sum(units) as volume,
location_id,
aged
FROM (
SELECT
units,
location_id,
CASE
WHEN daysinstock < 61 THEN 'NOT_AGED'
WHEN daysinstock < 91 THEN 'AGED'
ELSE 'OVER_AGED'
END AS AGED
FROM
STOCK_TABLE
) x
group by location_id, aged
the STOCK_TABLE contains the following fields: units, location_id, daysinstock.
This table is matched by a StockDataSource object, with the same fields.
I have one table with the following Column.
BoxNumber Status
580 4
581 4
582 4
583 4
584 2
585 2
586 4
587 4
588 4
589 4
590 2
591 2
I need one select Query to get the following output .
StartingBoxNumber EndingBoxNumber Status
580 583 4
584 585 2
586 589 4
590 591 2
Hello,
In my table I have a field named eventdate in datetime format like 2010-05-11 00:00:00.
How do i make a query so that it adds one day to the eventdate eg if today is 2010-05-11, i want to show in where clause to return all records with tomorrow's date.
Hi,
I have datatable with column name tag and 100 rows of data.I need to filter this table with tag starting with "UNKNOWN".
What should my sortexpression for datatable.select be ?
I'm trying the following.
Datarow[] abc = null;
abc = dtTagList.Select(string.format("tag='{0}'","UNKNOWN"))
How can I achieve tag startswith 'UNKNOWN' in the above code ?
Hi
How Can I Import Data From a Table in Sql Server CE To Excel?
I Try This From Excel But I Can Not Find an Item for This In Excel
Please Help Me To This
I have an application, and I would like to print a JTable, but since it has many columns, I would like user to select/limit which columns to print so it can fit in regular printer paper.
I'm using JTable.print() function to print. (http://java.sun.com/docs/books/tutorial/uiswing/misc/printtable.html)
Right now, my solution, is to create another JTable with the columns that user selected, then repopulate the table with the data, then send it to printer.
Is there a better way to do it?
Hi
this is my homework and the question is this:
List the average balance of customers by city and short zip code (the first five digits of thezip code). Only include customers residing in Washington State (‘WA’).
also the Customer table has 5 columns(Name,Family,CustZip,CustCity,CustAVGBal)
I wrote the query like below is this correct?
SELECT CustCity,LEFT(CustZip,5) AS NewCustZip,CustAVGBal
FROM Customer
WHERE CustCity = 'WA'
THANKS!!
Can someone explain me the way reusable cells works for single table view?
How many reusable cells a datasource should create? So far in all samples I've seen only one. Would one even need more?
Hello everyone,
I am using SQL Server 2008 Enterprise and using the new Merge statement. From my experiment, I find source is always read only (table content not modified, i.e. no record is deleted/inserted/updated)? Is that correct understanding?
thanks in advance,
George
I'm generating an HTML report by C# to print pairs of files in a table which has 3 columns: the first two columns used for the filenames and the 3rd column is a hyperlink Compare - I want this link to run WinMerge to compare to two files and I currently don't know how to do it. Please help!
I have one table, which has three fields and data.
Name , Top , Total
cat , 1 , 10
dog , 2 , 7
cat , 3 , 20
horse , 4 , 4
cat , 5 , 10
dog , 6 , 9
I want to select the record which has highest value of Total for each Name, so my result should be like this:
Name , Top , Total
cat , 3 , 20
horse , 4 , 4
Dog , 6 , 9
I tried group by name order by total, but it give top most record of group by result. Can anyone guide me, please?
i have two tables with images that parts of them are transparent and i want
to ignore mouse interactions (especially clicking) on these parts and assign the
click to the image in the other table that below.
(i hope you understand because english is not my native language.)
thanks..
Hi all.
i m working sql server 2005.
My query is:
SELECT (
SELECT COUNT(1) FROM Seanslar WHERE MONTH(tarihi) = 4
GROUP BY refKlinik_id
ORDER BY refKlinik_id) as dorduncuay
And the error:
The ORDER BY clause is invalid in views, inline functions, derived tables, subqueries, and common table expressions, unless TOP or FOR XML is also specified.
How can i use order by in a sub query?
I have a table called cc_calls and there I have many call records I want to count them and group them in months I have a timestamp called starttime and I can use that row to extract the month, also limit the count for 12 months
the results should be like:
Month Count
January 768768
February 876786
March 987979
April 765765
May 898797
June 876876
July 786575
August 765765
September 689787
October 765879
November 897989
December 876876
Can anyone guide me or show me the mysql query that I need to get this result.
Hi all
I have a sql query in formula tag inside property tag.
In that query i am creating alias name but the hibernate appends table name and throwing me error.
select sum(e.salary) as sal from employee e
but hibernate changes to
select sum(e.salary) as employee.sal from employee e
how to avoid this ....
it should recognise as sal inside of employee.sal !!!