Tracking Forums, Newsgroups, Maling Lists
Home Submit Tracker Forums
  Advanced Search
  HOME    TRACKER    ASP.NET


Advertisements:










Databases :: Join Two Sql Selected Statements


how to join 2 sql select statements in Oracle, which has different number of rows. That is I have first select statement which fetchs around 80 records in below format.

DATE MONEY
12-01-2010 10
12-01-2010 15
12-01-2010 15
12-02-2010 15
12-02-2010 15
12-03-2010 15
12-03-2010 15

Second statement will give reocrds like below. That is it will give only distinct dates. Please tell me how to join these two queries. So that I can get

DATE Rank
12-01-2010 a
12-02-2010 b
12-03-2010 c

how to join these two queries. So that I can get result set in below format.

DATE MONEY Rank
12-01-2010 10 a
12-01-2010 15 a
12-01-2010 15 a
12-02-2010 15 b
12-02-2010 15 b
12-03-2010 15 c
12-03-2010 15 c


View 4 Replies (Posted: Jan 25, 2010 04:30 AM)

Sponsored Links:

Related Forum Messages For ASP.NET category:
Databases :: 'join' Text Files Similar To Sql Left Join?
I have some text files I need to parse in order to display my data, and what I have now are two text files with lots of redundant data. Instead of this I would like to replace the redundant data with a number referencing the text in another text file.

Posted: Jan 31, 2011 06:49 AM

View 1 Replies!   View Related
ADO.NET :: Put A Right Outer Join On Linq Statements?
I am trying to put a Right Outer Join on Linq statements. how to put Right Outer Join on Linq.

Posted: Aug 02, 2010 07:47 AM

View 1 Replies!   View Related
Databases :: Alternative Way Of Writing SQL Statements
Can anyone come up with any alternative ways of writing the following statements?

SELECT position, AVG(pay)
FROM staff
GROUP BY possition
HAVING count(employeeID)>=2
ORDER BY AVG(pay) DESC;

SELECT name, pay
FROM staff
INNER JOIN division
ON staff.divisionno = division.divisionno
AND location='USA';

SELECT location, SUM(pay+NVL(comm,0)) AS "full"
FROM staff
INNER JOIN division
ON staff.divisionno= division.divisionno
GROUP BY location;

select name, position, pay, divisionname
from staff
inner join staffposition
on pay between losal and hisal
inner join division
on staff.divisionno= division.divisionno
where positiongrade = 32;

create viewstaff (name, area, zip)
as
select name, area, sip from stafftab;

Posted: Oct 07, 2009 06:59 PM

View 6 Replies!   View Related
Databases :: JOIN Same - Different Table In Different Databases?
I have a table where two of the columns are named "ItemA" and "ItemB". Both columns consist of numeric itemnumbers such as 1,22,55,195 etc. I often cobine these coumns with some form of JOIN or UNION which I have a feeling is very ineffective from a performance point of view, joining columns from the same table. Anyhow, it makes it hard to work with so I want to take ItemB out of that table.

So, my questions is: Is it better to put ItemB in a different table and do the JOIN/UNION between the tables? Or is it even faster to put ItemA and ItemB in different tables? Both ItemA and ItemB will be quite large.

Posted: Nov 13, 2009 08:39 AM

View 3 Replies!   View Related
Access :: Add Two Selected Statements
I want to add Sum contents from the two tables, Realize the rows could be different, Only like rows to be added rest of the rows from both tables are listed.

SELECT TYPE AS CashFlow, Sum(AceData.InCredit) AS Credit, Sum(AceData.OutDebit) AS Debit, Sum([InCredit]+[OutDebit]) AS Totals
FROM AceData
where case=1
GROUP BY Type;
CashFlow Credit Debit Totals
Advert $0.00 ($5,816.52) ($5,816.52)
BOND $0.00 ($3,060.00) ($3,060.00)
Cash $18,619.57 ($34,824.75) ($16,205.18)
Charity $0.00 ($6,578.00) ($6,578.00)
DayCare $0.00 ($2,360.00) ($2,360.00)
SELECT TYPE AS CashFlow, Sum(AceData.InCredit) AS Credit, Sum(AceData.OutDebit) AS Debit, Sum([InCredit]+[OutDebit]) AS Totals
FROM AceData
where case=2
GROUP BY Type;
CashFlow Credit Debit Totals
BOND $0.00 ($3,060.00) ($3,060.00)
Cash $18,619.57 ($34,824.75) ($16,205.18)
Charity $0.00 ($6,578.00) ($6,578.00)
DayCare $0.00 ($2,360.00) ($2,360.00)
Entertainmen $0.00 ($12,258.18) ($12,258.18)
Equipment $0.00 ($7,085.00) ($7,085.00)
Fee $1,957.63 ($27,611.85) ($25,654.22)

Posted: Feb 09, 2010 05:14 AM

View 4 Replies!   View Related
Databases :: MySQL And Auto Generating Insert,Update - Delete Statements?
Before I get too far down the road I just want some advice. I'm building a web app using VWD2008 and MySQL 5. I've got the membership provider stuff working fine and have an odbc connection setup which works "fine". what I've noticed is that when I configure a new sqldatasource (that will be used to provide data to a listview or something) the Advanced -> generate Insert,Update..... option is disabled. I'm assuming its because of the sql syntax difference of thesquarebrackets issue between MS SQL Server and MySQL.

Before I start writing all my own insert and update statements does anyone know if there is a way to get MySQL and VWD to talk the same language, maybe a different connector or something. I'm using mysql-connector-odbc-3.51.15

Posted: May 11, 2010 09:57 AM

View 7 Replies!   View Related
SQL Server :: Join Two Tables In Different Databases?
i need to join two tables in different databases, how it can be done??? and if i want to use sqldatasource control to bind results to some data-bound control how can I configure my sqldatasource control???

Posted: Sep 22, 2010 04:21 PM

View 3 Replies!   View Related
Databases :: Like Oracle Fragments To Join Them?
Is the any term like Oracle Fragments.Someone asked me about oracle fragments and if we can join them and how. I din't knew about it.

Posted: Nov 16, 2010 02:41 PM

View 1 Replies!   View Related
DataSource Controls :: Join Across Two Databases On (possibly) Different Servers
I would liketo create a gridview whereall of the items in one table are listed and a checkbox is checked if that item alsoshows up inanother table. The difficulty comes in the fact that table are not only in different databases, but possibly on different servers.

Is there any way to do this via ASP.NET connection strings, so that it doesn't matter where the databases live? I'd rather use connection strings, because I don't want to hard-code credentials into the queries (OPENROWSET or whatnot).

Posted: Feb 12, 2010 05:30 PM

View 1 Replies!   View Related
ASP Join Of Two Databases - Display The Proper Email Address
Iam havingan issue with ajoin statement. The join is based on thecustomer id in bothdatabases, however, I just happen to have the exact same spelling forthe email field which is contained in both the customer database and the office database.How do Idisplay the proper email address.Theemail I am sending sends to the office email address rather than the customer address.

Posted: Sep 22, 2010 12:07 PM

View 2 Replies!   View Related
SQL Server :: Join Tables Across Databases And Return An ADO Dataset
I need to join two tables accross two different databases and return an ADO dataset.

ie: select * from database1.table1 a inner join database2.table2 b on
a.key=b.key where some_condition=true

My main problem is how to specify the SqlCommand parameters specifically the connection string for both databses. Is this possible?

Posted: Aug 18, 2010 04:44 PM

View 4 Replies!   View Related
DataSource Controls :: How To Join Tables From Different Databases In SQL Select Statement
I have a basic sql statement, where I have a usersID, and I want to joing that usersID to another table in another database to get the users first and last names. How do I join across databases... each with a different connection string?

Here's what I want..

Select usersID from tableA in databaseA, and usersFirstName, usersLastName from table B in database B where the usersID from tableA = the usersID in tableb.

Posted: Apr 30, 2008 02:32 PM

View 6 Replies!   View Related
Web Forms :: Join The Id's Of The Selected Checkboxes In A Checkboxlist
I got a checkboxlist inwhich I bind the items with data from theDB.Means the rows inmy table re directlybind tochkboxlist todisplay asthe 7listitemsin it.Together with that am binding the state also(ie,whther it is previously checked or not by the user).Now the user have the option to edit this settings by checking or unchecking the listitems in it.We need to update this in the DB accordingly.

I need to pass the Id's of the checkd items separated bya "|"along with the state 1 or 0.Meaning if the user check 1st threecheckboxes in the list my parameters shud be (userId,1|2|3,1|1|1)..I tried in the below way..

public
void UpdateNotificationSettings()
{
NotificationDO notifyDO =
new NotificationDO();

[Code]....

Posted: Jan 09, 2011 01:01 PM

View 2 Replies!   View Related
DataSource Controls :: Update / Insert And Delete SQL Statements For Define Custom Statements Wizard
I'm using the 'Configure Data Source' wizard to connect to my database and show the dataset in Gridview. I want to be able to update, insert and delete entries but am unsure how to build the query. I can write simple update statments to change database entries but how can I do this for entries that have been changed within the gridview?

Posted: Feb 23, 2011 10:14 AM

View 6 Replies!   View Related
DataSource Controls :: Fetch Record Using Join Query When One Join Condition Is True?
Towrite ajoinquery with or condition. It means a query has two inner join, here it is possible to fetch the records, if one inner joinistrue and other is false. I got a record when onlytwo join conditions are true.

Posted: Feb 18, 2010 05:00 PM

View 1 Replies!   View Related
ADO.NET :: Forum Function Using Linq, Group, Distinct Left Join, Join?
I'm trying to build a linq2Entity/gridview function for a forum, that draws data from multible tables.The result should be: Get the latest 10 threads that user(xx) has replyed in, that is not disabled or has a subject that is not allowed.Include information on the last post, thread owner user, and last post user,in each thread.
ere is my code... is returns the correct threads and some that should not be there.

[Code]....

Posted: Mar 24, 2011 04:54 PM

View 1 Replies!   View Related
DataSource Controls :: Where Inner Join Should Be Used And Where Outer Join Should Be Used?
where we should use inner join and where we use outer join with some easy and understandable examples.?

Posted: Dec 03, 2009 04:04 PM

View 1 Replies!   View Related
Databases :: Assign Selected Value Into Variable
I m using stored procedure and want to assing a value selected by a query into a variable. The procedure is like

declare id int(10);
select storeid from store where store=@storename;

now i want to assign storeid into id how can i do it in MYSQL. i used

select storeid into id from store where store=@storename;

but id shows null value.

Posted: Dec 24, 2009 07:54 AM

View 6 Replies!   View Related
ADO.NET :: Join 3 Tables Using Inner Join?
i need join 3 tables using inner join...

Posted: Sep 08, 2010 11:40 AM

View 6 Replies!   View Related
AJAX :: To Get The Selected Index,selected Value , Selected Text Using Javascript Of Combobox Control
Can i get the selected index,selected value , selected text using javascript of ajax combobox control. if yes send me the sample code.

Posted: Feb 17, 2010 04:31 AM

View 7 Replies!   View Related
Understanding Of SQL Statements?
string sqlstring =
"SELECT DISTINCT STAFF_ID, SCHOOL_CODE FROM MODULE_TIMETABLE_STAFF WHERE STAFF_ID != '" +userId +
"' AND STAFF_ID LIKE '%" + Searcht +
"%' ORDER BY STAFF_ID ASC";

can anyone explain this statement for me? especiallythese signs!=,+ +

Posted: Jan 03, 2011 03:23 AM

View 4 Replies!   View Related
How To Convert 20 SELECT Statements Into 1
I am making a client website, and need some advice. Take a look at this URL:-

[URL]

The list of nurseries you can see currently have separate SELECT statements for each region. The region name i am simply writing this to a label.

Now at the moment i have ALOT of SELECT statements saying select * from tbl_nurseries where region = 'Bedfordshire', and so on..

But how can i condense this code and display the results i exactly the same way but with less code?

Posted: Nov 3, 2009, 04:14

View 12 Replies!   View Related
How Mathematical Statements Get Executed
to a good reference link on why the following code snippet causes an overflow exception during the multiplication statement. I figure it has to do with how Mathematical Statements get Executed, but I would really
like to understand the issue.

Dim Var1 As Int16 = 10
Dim Var2 As Int16 = 8
Dim Var3 As Int16 = 8
Dim Var4 As Int16 = 10
Dim Var5 As Int16 = 10
Dim Result As Int32

Result = Var1 * Var2 * Var3 * Var4 * Var5

Posted: Nov 17, 2009 06:52 PM

View 3 Replies!   View Related
SQL Server :: How To Schedule Several Statements
How can I schedule several statements that involve select ... into ..., delete, and exec one other stored proc, periodically? For instance, every 6 hours, in Sql serverDB

Posted: Aug 02, 2010 08:33 AM

View 1 Replies!   View Related
ADO.NET :: Include More Than Sql Statements Into SqlReader
i want to execute more than one query in a page.i tried to use sqlreader it didnt allow me to include.how to do ?This is my code.

[Code]....

this is how i did.it shows me error.how to solve this error?

Posted: Jan 02, 2011 06:00 PM

View 3 Replies!   View Related
Define Using Statements In Web.config?
I'm using MySql in my asp.net project. But I don't want to type every "using MySql.Data.MySqlClient;" statement in every aspx.cs/aspx.vb file. How can I define this lines in web.config file?

I've defined some namespaces like below but this only works for aspx pages:

<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="false" targetFramework="4.0"/>
<pages>
<namespaces>
<add namespace="System.Web.Configuration"/>
<add namespace="MySql.Data"/>
<add namespace="MySql.Data.MySqlClient"/>
</namespaces>
</pages>
</system.web>
</configuration>

related question : Define common namespaces for code pages in Web.Config

Posted: Apr 16 10 at 11:33

View 3 Replies!   View Related
C# - Conditional Statements Difference?
Is there any difference between below two statements

if (null != obj)

and

if (obj != null)

Edit: if both treated same which will be preferable?

Posted: Feb 10 at 13:40

View 7 Replies!   View Related
Prepared Statements With Sql Server 2008?
I need to do lots of updates/inserts with small data (1k) in one transaction. However I'm thinking that doing 1000 updates is much slower than doing 1 update with 1MB data. The table would have only 2 columns (id, data).

But I don't know how to implement it. Using prepared statements means I would have to do those many small updates and I can't send to sql server an array of data.

Posted: Mar 8, 2009, 03:53

View 8 Replies!   View Related
How To Print A Line In Between Select Statements
i want to print a dotted line inselect statements. my requirements is i have tow table from two table i have select data and print a dotted line (ex.like that--------------) after first select result:

TableA Table B Result should be like that

d1 G1 d1

d2 G2 d2

d3 G3 d3

G1

G2

G3

Posted: May 20, 2009 05:13 AM

View 1 Replies!   View Related
Use Databind Records In Inline If Statements?
I've got a repeater on my asp.net (VB):
<asp:Repeater ID="Repeater1" runat="server">
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Eval("Question_Number") %>' />
<%#Eval("Question_Desc")%>

Now what I want to do is, check a value that I haven't used called "Question_Type" which could be = 1, 2 or 3 depending if it is multiple choice, short answer, etc. I have tried this:

<%
if Eval("Question_type") = 1 then
Response.Write(" <asp:RadioButton runat=""server"">test1</asp:RadioButton>")
Response.Write(" <asp:RadioButton runat=""server"">test2</asp:RadioButton>")
Response.Write(" <asp:RadioButton runat=""server"">test3</asp:RadioButton>")
end if
%>

and I get this error: Databinding methods such as Eval(), XPath(), and Bind() can only be used in the context of a databound control. HOW can I use this value in a if statement?

Posted: Mar 10 10 at 18:30

View 1 Replies!   View Related
How To Make If Statements In Databound ListView
I have a ListView with many advanced controls and html tags. ListView is bound to collection of profiles when first profile in collection is current profile. current profile has few differences from other profiles ie. flash embed, js and some other stuff. I can access inside of my ListView Container.DataIndex property which gives me 0 as first item in index but i'm unable to use inline If statements like so

<% If Container.DataIndex = 0 Then %>
do stuff
<% EndIf %>

this is because i must place pound to access databound item but neither this

<%# If Container.DataIndex = 0 Then %>
do stuff
<% EndIf %>

How can i make inline If ?

Posted: 2 days ago

View 2 Replies!   View Related
ADO.NET :: Configure Both Select And Update Statements?
i would like to retrieve a value with select and perform a calculation and thensave usingupdate in the same batch code?

Posted: Sep 06, 2010 10:15 AM

View 3 Replies!   View Related
MVC :: Razor Multi-Token Statements In VB.NET?
Multi-Token Statements

The @( ) syntax enables a code block to have multiple tokens. For example, we could re-write the above code to concatenate a string and the number together within a @( code ) block

Posted: Dec 17, 2010 07:39 AM

View 5 Replies!   View Related
WebMatrix :: Support For Shorthand Statements?
Will there be support for shorthand statements?

Example:

[Code...]

as apposed to;

[Code...]

perhaps ternary opperators?

Posted: Aug 18, 2010 04:30 PM

View 2 Replies!   View Related
Prevent Deep Nested IF Statements?
What is the best way to prevent deep nested statements. I'm looking at apieceof code which is 7 statements deep, and it is massively un-readable!

Posted: Jun 04, 2010 11:50 AM

View 3 Replies!   View Related
Web Forms :: VB.NET - Import Statements And Base Classes?
I have a BasePage class that all of my content pages inherit from. In my BasePage, I have many Import Statements. It seems as though they carry over into the derived class as one would expect. However, if you were to try and access code in the client aspx design page, as you would in the code-behind, you run into problems.

For instance, in my BasePage i have a Public Enum named ThemedSites. It's just an enumerator that lists the 5 different themes my site could be skinned as. I, at times, need to do different things in code, and in design, depending on what theme I'm currently in. I have a Public Property named CurrentSite (might have been more appropriate to say CurrentTheme, but that's besides the point). CurrentSite's return type is ThemedSites. So in code, one would say something like:

[Code]....

This works great in any page that inherits the BasePage class. This falters when that very same logic is used in the design page like:

[Code]....

Now, it works if you fully qualify both sides of the condition, but that's not my question. My question is: why isn't the Imported NameSpace in the BasePage recognized in the client-side server tag, as one would think it would be, according to how it IS recognized in the server-side code-behind?

Posted: Aug 19, 2010 05:05 PM

View 3 Replies!   View Related
ADO.NET :: Records Count Not Matching Between Linq And SQL Statements
I am facing an intresting problem now with entity framework. if i did a count of the some table with linq statement its give some count and it is not matching with my normal sql query count. my sql query returning count of all the records in that table where as linq query returns some count which is less than sql count. is this a problem with my edmx or table navigation properties..i do have some 5 to 6 child tables inside this table with foreignkey relation. will it do a join on each child table and returns only those records. I am very much confused and don't know how to slove this.

Posted: Mar 17, 2011 05:23 PM

View 9 Replies!   View Related
DataSource Controls :: Using Case When In Select Statements Of Sql
I am filtering the results of a gridview based on selected values from a drop down list. This all works fine except that I'm trying to provide for the case that if no value is selected on the drop down list, the gridview will display all results. So, based on some other posts that I've seen on this forum, I've tried to incorporate a CASE statement in my SelectCommand for the sqldatasource of the gridview.
Here is the code:

<asp:DropDownList ID="ddlBuilding" runat="server" AppendDataBoundItems="True"
AutoPostBack="True" DataSourceID="dsdBuilding" DataTextField="BuildingName"
DataValueField="BuildingName" Height="28px" Width="200px">
<asp:ListItem Selected="True" Value="-1"></asp:ListItem>
</asp:DropDownList>
<asp:SqlDataSource ID="sdsPO" runat="server"
ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
ProviderName="<%$ ConnectionStrings:ConnectionString.ProviderName %>"
SelectCommand="SELECT [PONumber], [Employee], [BuildingName], [ClientName], [OrderedBy], [DateOrdered], [VendorName], [DueDate], [DueTime], [DeliverTo], [DeliverToOther], [SpecialInstructions], [Approved] FROM [PO] where [buildingname]
= (CASE WHEN @Building = '-1' THEN [buildingname] ELSE @Building END)">
<selectparameters>
<asp:controlparameter controlid="ddlBuilding" name="Building" propertyname="SelectedValue" />
</selectparameters>
</asp:SqlDataSource>

This seems like it should work but when I run the website I get the following error when this particular page is loaded:

IErrorInfo.GetDescription failed with E_FAIL(0x80004005).

Can anyone tell me what I'm missing?

Posted: Dec 31, 2009 12:00 AM

View 4 Replies!   View Related
Architecture :: Option To Using Enums And Switch Statements?
Is there any design pattern or architectural design that prevent the following type of code, where I have an enum with different fileformats andI have to make a switch anywhere Iwant to distinguish between the different fileformats?

[Code]....

If add an item to the enum definition in this caseI have to change all the code that uses switches and that kind og enum which, I guess, is a bad approach in terms on maintenance of the application?

Posted: Oct 26, 2010 09:11 AM

View 1 Replies!   View Related
Copyright 2005-08 www.BigResource.com, All rights reserved