DataSource Controls :: SQL Select Statement - Values To Appear In Same Query

Feb 15, 2010

I am having difficulty selecting data from 2 tables that do no share a primary key value. For instance, I have an actual table, a forecast table, and a GLText table. I may have an actual value but not a forecast value but I need them to appear in the same Query (like the query results shown below). I can get all values to appear in each table but have been unsuccessful in getting all values from both tables.

View 5 Replies


Similar Messages:

DataSource Controls :: Return Values From Select Statement?

Feb 8, 2011

I have a select statement in a stored procedure and want to be able to retrieve the key column value (PRODUCTID)and return it as Output when Select statement is executed on input Parameter (NAME).

addition, return two further output values (COST,TOTAL).

note the grid control expects to receive all values at once! so i need to get out these values at the same instance of execution.

Select productID,COST,QUANTITY,NAME,TOTAL,DATE
FROM PRODUCTS
WHERE NAME=@NAME

View 2 Replies

DataSource Controls :: Filtering Between 2 Values In A Query From Dropdownlist Select?

Feb 17, 2010

I have dropdownlist of dates and depending on the date that the user selects from list, I would like to filter records that fall between the startyear and finishyear columns in the datasource. (My the problem is that I do not know how to declare the Startyear and Endyear from the query in the code as they appear underlined - probably the BETWEEN syntax is wrong too).

yYear = DropDownList1.Text
Using connection As New SqlConnection("Data Source=CHRIS-PCSQLEXPRESS;Initial Catalog=TorGHL;Integrated Security=True")
Dim cmd As String
cmd = "SELECT BarDetails.*, MenuHeadingId AS Expr1 FROM BarDetails WHERE (MenuHeadingId = 2)" & "WHERE " & yYear & " BETWEEN " & "(" &
StartYear & ")" & " AND " & "(" & EndYear & ")"
connection.Open()
Dim dapubcb As New SqlDataAdapterDim sqlcomm
As
New SqlCommand(cmd, connection)
dapubcb.SelectCommand = sqlcomm
Dim dspubcb As New DataSet("BarDetails")
dapubcb.Fill(dspubcb, "BarDetails")

View 4 Replies

DataSource Controls :: Write Select Query To Get Counts In Row Values?

Jun 2, 2010

How to write select query to get counts in row values

View 6 Replies

DataSource Controls :: Using Values Selected From A "check Box List' In A SQL Select Query?

Jul 5, 2010

I have a table called 'Customer' that contains customer information. One of the fields is named "CustomerType". Each record in the 'Customer' table will contain the value of either "C", "I", or "O".

I have a form that contains a "check box list" named "Type". There are 3 values in the "check box list". The values are "C", "I", and "O". The user can select one or more of these values. I have a button on the form named "btnRunQuery.

When the user clicks on the button "btnRunQuery" I want to exectute a query that selects the records contained in the "Customer" table where the value in the field "CustomerType" equal the values the user selected in the "check box list". Example: If the user selected "C" and "O", then I want the select query to select all records that contain either "C" or "O" in the field "CustomerType".

I assume that what I need to do is to capture the values that the user selected in the "check box list" and put them in a variable. Then I need to format the "Where" statement in the query and add a "Parameters.AddWithValue" command.

View 2 Replies

ADO.NET :: Sql Query Select Inside A Select Statement?

Dec 2, 2010

i have two tables named

1.LookupPageInfo and (LookupPageInfoId,pathmessageID,pagemessageID)

2.Messages (MessageId,MessageText,ChannelID)

Now i need to write a query something like this........in the query i need to pass the pathmessageid and needs to get messagetext from Messages Table,i am not sure how i need to write the below query..can someone guide me how can i write a query......as below..

select LookupPageInfoId,
PathMessageID,
pagemessageID,
(select messagetext from Messages where MessageID=PathmessageId) as TEXT from LookupPageInfo

View 5 Replies

Make Select Statement Select Row With Nearest Values?

Oct 23, 2010

How would i make a select statement select the row with the nearest values? e.g.: I have 3 labels, labels1 2 and 3, with values of 1.2, 2 and 5.8 In my table i have 4 columns, first is the data im after, and the next 3 relate to the three labels. I want to select one row, where the values of labels match it the closest.......

View 8 Replies

DataSource Controls :: Select Top Record From Sql Statement

Mar 17, 2010

If I run the following SQL script:

[Code]....

View 3 Replies

DataSource Controls :: How To Select Statement For Some Scenario

Apr 24, 2010

I want the select statement for the above scenario.

View 2 Replies

DataSource Controls :: INSERT SELECT Statement?

Apr 30, 2010

How would you handle an INSERT that gets some values from another table using SELECT, where you wanted some values to come from the source table record and other values to come from a different parameter source like a session value? Is this possible?

View 3 Replies

DataSource Controls :: Executing The SP Across Select Statement?

Apr 17, 2010

I need to execute the stored proc accross the parameters resulted from select statement

I have created one stored procedure which require one parameters ( username ) ..

i need to execute this SP accross the Select Statement which lists all the username

somethibng like :

Set @username = (Select usename from my table)
EXEC dbo.Duplicate_Data @username

View 7 Replies

DataSource Controls :: Select Statement Across Three Tables?

Mar 17, 2010

[Code]....

Select statement across three tables

View 15 Replies

DataSource Controls :: Select Statement Excluding TOP 10?

Jul 6, 2010

I need to create a SELECT statement for a table that excluded the TOP 10 records.

"SELECT TOP 10 field1,field2,field3 FROM AppData ORDER BY field1 DESC" returns the first 10 records from the table but I need to retrieve only from the 21st record onwards.

I simply don't know how to do it because I'm not that strong with SQL. I searched the forum for some answers but can't find a solution that I can understand.

View 4 Replies

DataSource Controls :: Insert Query Statement?

Aug 16, 2010

I have SQL Details View insert statement, I need to have a Condition checked for the Insert Query. The condition is, I do have a table by name table1 with the No of Questions (for Eg: 10). The insert statement shud insert data to the table2 (Another table) only if the no of rows is less than or equal to 10 else it shud give me a message (It has exceeded the no of questions).

View 3 Replies

DataSource Controls :: Select Statement To Get Order By Date?

Apr 27, 2010

i get this data from history table for a paricular ConsignmentNo.

................

i want the sql statement. 1st condition is sql statement should be order by CurrentStatusDate.

.......................

View 13 Replies

DataSource Controls :: Updating Field Using Select Statement?

Feb 24, 2010

I have a table "Table1" which has mani 3 fields ID: int,

Date1: datetime,

Date2: datetime

All fields are filled except Date2, so I want to copy the records in Date1 to Date2I tried this query, but it didn't work

[Code]....

View 3 Replies

DataSource Controls :: Select Statement By Multiple Dropdownlist

Feb 25, 2010

if I have three Dropdownlist A, B, C, how can I write a select statement to get data from sql server based on the dropdownlist selected.e.g. if user select dropdownlist A, select * from table where A = dropdownlist A but if user select dropdownlist A and C, then select statment is "select * from table where A = dropdownlist A and B = dropdownlist B or if selected A, B, C.......how can I settle so many choice.

View 2 Replies

DataSource Controls :: Count From Several Tables In One Select Statement

Mar 14, 2010

I am trying to count records belonging to a certain person in three different tables in a single select statement. The database looks like this:

Player
-PlayerId
-Name

Game
-GameId
-TournamentId
...

Goal
-GameId (FK->Game.GameId)
-PlayerId (FK->Player.PlayerId)
-Assist (FK->Player.PlayerId)

Card
-CardId
-GameId (FK->Game.GameId)
-PlayerId(FK->Player.PlayerId)

I want to select the number of goals, assist and cards a player has in a specific tournament. I tried with this query but then the goal and card column shows the sum of the number of rows matching the playerid in the Goal table and the Card table...For example if there is two matching rows in the goal table and three matching rows in the card table, I get 5 in both these columns in the resultset.

[Code]....

View 3 Replies

DataSource Controls :: Display The Table Name In The Select Statement?

Feb 23, 2010

I need to display the table name in the select statement. how?

exact question:

we have common columns in two tables. we are displaying the records by using

select column_name from table_name_1 union select column_name from table_name_2

But the requirement is, we need to display the source table_name along with the data. consider a,c are present in table_1 and b,d are present in table_2. we need the output in the following way

eg: column_name table_name a table_1 b table_2 c table_1 d table_2

View 2 Replies

DataSource Controls :: Use A Stored Procedure In A Select Statement?

May 25, 2010

Just quick question, is it possible to Use a Stored Procedure which has a parameter in a select statement,, I mean something like the following

SELECT A, B

FROM Something

-- Something is the name of the Stored Procedure which take date parameter

View 2 Replies

DataSource Controls :: How To Add Condition In Select Statement For Datedifference Function

Mar 5, 2010

this is my select Statement.:-

Select (datediff(day,db_TargetDate,getdate())) from tbl_abc

in select statement only i wanted only those record in which datedifference is less than 5.

declaration of variable & then conditional checking is not wanted me because i wanted result is into select statement only & not using print statement.

View 11 Replies

DataSource Controls :: Select Statement Pulling Multiple Times From Same Row

Jan 5, 2010

[Code]....

I have a select statement that is supposed to be filling grid with information from an income table. It's only supposed to pull if the income is from the current fiscal year or is less than 1 year old. Currently, what it does is pull multiples of rows and also rows from past income years but only if there is a mixture. For instance, if a person has income from 2005 and 2010 what it will show is this

Income 2005
Income 2005
Income 2010
Income 2010
Income 2010

Does anyone know what I've done wrong? BTW, those results are exact, old income is shown twice, current is shown 3X

View 16 Replies

DataSource Controls :: For Each Row In Select Statement - Exec Stored Procedure

Apr 21, 2010

Ive been banging my head against the wall for the last 2 days with this query I am trying to produce. I have an application that creates requests and these requests have status codes dependant on how far along in the process they are : new request, awaiting approval, approved, in progress, complete When a request is moved to the next status, it Inserts a row into an auditing table, so we can track who moved it onto the next status, along with a timestamp. There are Service Level Agreements in place that mean that a request that is currently 'In Progress' must be actioned to 'Complete' within 5 days. I have been asked to create a query that will return all records that fall outside of this SLA. My main problem is trying to Select the time from the audit log for 'In Progress' and 'Complete' status codes. It would be simple if i only had to find one of the times, as i could add a "WHERE StatusCode = 'complete' clause to the query My Audit table is structured as follows:

[RequestID] [Request Status] [UserID] [CreateDate]

So far I have been successful in querying the table by using the DATEDIFF() function as below:

SELECT
DateDiff
(day,
( SELECT
top 1 CreateDate
FROM audit_tblRequest
WHERE RequestStatus
= 'In Progress'
AND RequestID
=
@RequestID Order
by CreateDate
DESC)
,(SELECT
top 1 CreateDate
FROM audit_tblRequestWHERE RequestStatus
= 90AND RequestID
=@RequestID
Order
by CreateDate
DESC)
)

This will return the difference in days to me, however, i cannot figure out how to integrate this into a query that will be run across all RequestIDs. I was wondering if there was any way to bundle the DateDiff function into a stored Procedure and be able to call it For Each RequestID in the result set I would need to pass the requestID as a parameter, and also add some If Else logic to only return records outside of the 5 Day SLA. Im sure there are some patches in the above logic, but my brain is about to explode and I needed to type it all out before calling it a day for today.

View 3 Replies

DataSource Controls :: Combine Multiple Columns Into One For Select Statement?

May 14, 2010

This question is for wrapping up work on a database driven AJAX AutoComplete Control that I am using to provide keyword hints to user on search pages. Each record has 6 columns for keywords where each column is for an advertiser to add a keyword. These are used in meta keywords tags, but I also want to use them for AutoComplete. The problem is that I don't know how to write a SELECT statement in Visual Studio that treats all 6 keyword columns as if they were all one column. I am looking for something like

SELECT (keyword1 + keyword2 + keyword3) AS Keywords
FROM (Merchandise)
WHERE Keywords LIKE @term

The only other thing I can think of the gain this level of functionality would be to combine them into a new table.

View 7 Replies

DataSource Controls :: Need To Get A Number Of Results And Do It In One SELECT Statement Or Just One Result Set?

Jan 14, 2010

Im using SQL Server 2005 and im using stored procedures. Is this possible? i need to get a number of results and do it in one SELECT statement or just one result set. Im using MS Chart Controls for reporting and they cant seem to process multiple result sets this is my problem, so basically to run a barchart i need to assign a column to the X axis and a column to the Y axis and it will then display my results.

My stored procedure below returns a result set with columns subpolicy_name, building_name, floor_name, room_name and total_savings. Im just wondering is it possible to split my total_savings column into 4 columns, for example subpolicy_savings, building_savings, floor_savings and room_savings, i need everything in a separate column. If you run this stored procedure you will see the result set.

[Code]....

View 5 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved