Databases :: Multiple Select With Single Group By?
Jun 24, 2010if we are trying to add the several columns in select statement and only one condition in group by.
how can we do that ?
Example:
[code].....
if we are trying to add the several columns in select statement and only one condition in group by.
how can we do that ?
Example:
[code].....
I have a query which gets values from two tables which are in different databases.How can I write a SINGLE Connection String which connects to two databases? By the way I am using SQL Server Database
View 7 RepliesI am making project on hospital management which will contain different databases for different hospitals. how can i manage this thing with single asp.net project?
View 4 RepliesI have three ListBoxes each representing a single field database table. They are presented side by side on the ASP.NET page. Is there any way to group them so that only a single item from any of the boxes can be selected at a time?edit - ie, if item 3 in box 1 is selected, selecting any item in box 2 must unselect it
View 1 RepliesI need to insert/update data to 3 or more tables on a single button click.What is best method for achieving this?I am using mysql as my DB.
View 2 RepliesI am using MS SQL Server 2005 & here is my problem: I need to assign values to the multiple variables in a single select. But each value is depend on the certain value of the other column of the table.
declare @i1 Int, @i2 Int, @i3 Int;
select
case Table.column1
when 'red' then @i1 = Table.column2
when 'green' then @i2 = Table.column2
when 'blue' then @i3 = Table.column2
end
from
dbo.Table
how to achieve this in a single select?
Stack-Overflow :3 I've got a kind of hard-case question.
So I'll try clearly explain my idea with my poor english :/ need select to DataTable SOME values from ???_**GetDisplayData **procedure for each day of previos month (GROUP IT) where group rules for different columns is different
I need to select some values in stored procedure from other stored procedure like this :
SELECT X FROM Y_Procedure(@ProcedureParameters)Also I need to select from dynamic SQL Procedure like
Y_Procedure=@Y+'_Procedure'
SELECT X FROM Y_Procedure(@ProcedureParameters)
Also I need to load it to DataTable :-/INSERT INTO @Report (CellHorizontal, CellVertical, CellValue) --to TABLE
SELECT Date,X2,X3 FROM Y_GetDisplayData(@Param)
SET NOCOUNT OFF;
SELECT *
FROM @Report
GetDisplayData works as select with parameters and that doesn't returns SQL DataTable
And there is no way to recode GetDisplayData's procedures, it's just constant procedures for me.Finally I need to Group nodes from this table
INSERT INTO @Report (CellHorizontal, CellVertical, CellValue)
SELECT T1.Date,
IF ((Select grouptype...)=1) T1.X2 + T2.X2
ELSE IF ((Select grouptype...)=2) AVG(T1.X2,T2.X2),
IF ((Select grouptype...)=1) T1.X3 + T2.X3
ELSE IF ((Select grouptype...)=2) AVG(T1.X3,T2.X3),
(SELECT T2.Date,X2,X3 FROM Y_GetDisplayData(@Param) T2
WHERE T2.Date>T1.Date AND T2.Date>=T1.Date)
FROM Y_GetDisplayData(@Param) T1
GROUP BY EVERY DAY ???--and here is epic fail
I can make all stuff on asp server :And C# allows me to use something like SelectCommand = IzmProc + "_GetDisplayData"; And then I will work (select special data) with DataTables on ASP.NET Server but it's better to make all on SQL ... But looking like it's just unrealizable on SQL >_<
I gonna think about C# realization,but my code is very weird , got errors and doesn't works >_<
public static DataTable GetReport(string Param)
{
System.Configuration.ConnectionStringSettings connSetting = ConfigurationManager.ConnectionStrings["FlowServerConnectionString"]; [code].....
When can I use Stored Procedure? Is this useful for looping into multiple SELECT statements to return single value? How? Can anyone post some sample codes? I have text query and notice that my web application is slow and want to find ways to speed it up. Is there any possible ways aside from Stored Procedures?
View 4 RepliesI have a stored procedure that returns 3 tables within the single recordset it returns. If I set a SqlDataSource to get data from this procedure, it works, but it only returns the first table. I want to have a GridView display the data from the 2nd or 3rd table using a SqlDataSource, but I can't figure out how to specify a particular table.
While there are some posts discussing this out there, I can't get a definitive answer about whether or not this is even possible (?). In a worst-case scenario, I can create another SP that only returns the 3rd table - but that creates a little maintenance headache that I would prefer to avoid.
Is it possible to group the values of different textboxes to a string....
View 1 RepliesIm a newbie in sql.. I have a query which display a list of program by college..This is the example:
my problem is the user wants the report to be display followed by college..like this:
i try to do select by select query but incorrect..anyone having the same xperience...?
I'm trying to set up two check box's in a DataGrid so that only one can be checked at any one time.
At the moment, the following renders the existing state of the choice on screen:
[code]....
How do I go about ensuring that if the user chooses ChoiceOne that any selection of ChoiceTwo will be unselected and vice versa? Is there any way to state in the DataGrid control that these two checkboxes are grouped together?
How to validate a group then render a single error message?
Below returns error message on each field.
[code]....
i want to develop a data access layer ,it can support multiple database like oracle ,Mssqlserver and Mysql using enterprise library and C#.net 3.5 based on database connection
View 1 RepliesDataContext db = new DataContext(conString);
var dvd = db.GetTable<DvdList>();
var query = from b in dvd
[code]...
how can i select a group of buttons that changed it's colour and i have to save it's textt as value in database can i do that
View 3 Repliesi have two tables (Users, Roles) and each user belongs to one role. Can I make a sql query that returns 10 newest users from each role in one query?
View 5 Repliesbelow written question :
1.) What is the name of the OS process in which App Domain resides.
2.)if suppose There are Three Windows application hosted on a same envoirment and two instance is working for each application at a Time, means now total instance are six .what will happen among the below written cases :
a.) There will be six different app domain in a single OS process
b.) There will three app domain(one for each application) in a single OS process and some Parallel thread will be executed in each app domain for another instance.
c.) There will be Three OS process corresponding to each application.
3.) If eveything will remain same except there are three web application in place of windows in point 2, will there be any change in functioning.
I have a question in gridview, I want to combine my two or more records into a single cell with two rowsfor Example i have a ID, Name, Year Start, and Year End for Column name in database and i want call it into my gridview that the Year Start and Year End will combine to Year like:
In Database
ID Name Year Start Year End
1 Yourname 2010 2015
In Gridview:
ID Name Year
1 Yourname 2010 2015
in a year column i want it to two row..
I want to bind three column with one row in gridview in asp.net with c#,
i want like this,
Name | Info
----------------------
name | lastname
| phone number
| address
I get this by default
name | last name | phone number | address
I am trying to design my logic to do this but I want to create a dataSet which will have records from several databases, The records all have the same layout.
I am reagin the connection string paths from a table in a database.
I am asking for your help in trying figure out my logic.
Should I use the connectionString builder in conjunction with a loop to Connect, read a record into a dataset Until therer are no more records to be read from my databse table with the database name/paths tables ?
Here is my beginning code which deals with one database:
[Code]....
i am developed on simple user registeration application in that i gave address field .when i am trying to enter something like this (1st main,b'lore) but wont take while inserting.
my query is
sqlcommand cmd=new sqlcommand("insert into registeration_form(name,address)values('"+txtname.text+"','"+txt_address+"')",con);
how can i pass the quotes also to my query if any one know reply me.
I have made a query based upon that the output is come as follow:-
[Code]....
Output should be like this:-
[Code]....
Means we need to concat all serial no in one row itself for a single group of data.
I have the below code. I want to validate at least one rediobutton to be selected from the group of radiobuttons.
[code]....
In the output i am getting morethan one radio buttons depending on the data which i added in the database. Before submit i want to validate atlease one radiobutton to be selected using javascript.
Using Linq to Sql how do i group the following 2 tables.
Orders Table:
CustomerID | Name |Date
1 | order1 | 2010-01-01
2 | order2 | 2010-01-01
2 | order3 | 2010-04-01
Calls Table:
CustomerID | Name |Date
1 | call1 | 2010-01-01
3 | call2 | 2010-06-01
2 | call3 | 2010-05-01
I want to group the two tables by date , Result:
Date | Orders | Calls
2010-01-01 | 2 | 1
2010-04-01 | 1 | 0
2010-05-01 | 0 | 1
2010-06-01 | 0 | 1
i know how to group a single table ,from o in Orders group o by o.Date.Date into og select new {Date = og.Key,Orders= og.Count()};