Simple Query
i want to force a sqlserver6.5 to return all rows in this query:
declare @id char(10)
set rowcount 1000
set nocount off
select @id = id from table
set rowcount 1000
select @id
The query only returns the first record. How can return all rows?
many thanks
View Complete Forum Thread with Replies
Sponsored Links:
Related Messages:
Report Wizard Doesn't Take A Simple Query In The Query String - Query Works In Query Builder When I Supply The Parameters
The following query in the query string: execute p_rpt_cli_v_index_reg_adj_exp_by_bkt2 @as_of_date='06/06/2007', @client_type=3, @index_as_of_date='05/31/2007' produces following error: There is an error in the query, invalid object name '#CLI_1', Invalid object name '#index'. When I open up the query Builder, and provide the same query and run, it asks for those 3 parameters values and after I provide those parameters, the query runs, but, clicking on Ok, produces same error as above in the 'Microsoft Report Designer' information window. The above query works in the Query Analyzer fine. What's so different in the Reporting Services env?
View Replies !
View Related
Simple Sql Query
hi,i have three fields in the database tablep1 p2 rank10% 20% 3 21% 40% 2now i am passing the input as 15%...this 15% is related to 3rd rank.. so i need the o/p rank as 3..if the p1 and p2 datatypes are varchar..then how we can we write the query for that one tgo get the rank as 3.Ramesh
View Replies !
View Related
I Need Help With A Simple Query
I have a table called "member" that has two fields (amongst others) called "firstname" and "city"I want to return a list that sorts people who live in the same city, but does not return people who do not have a city in common.For example if this is my data:Karen - ParisMike - RomeTim - Dallas Jim - ParisChris - DallasJohn - ManhattanSarah - OrlandoDavid - DallasThe query would return this:Dallas - ChrisDallas - DavidDallas - TimParis - JimParis - KarenI have this SQL so far: Select city, firstname From member Order By city, firstnamebut it includes all the cities including those that only have 1 resident.Can someone tell me how to do this?Thanks a lot,Chris
View Replies !
View Related
Help With A Simple Query
I am trying to make a single display page for an author's books.the books page only displays books of a type "type" (novels, non-fiction, etc)I would like to make it so that it can also show all books if "type" isn't selected. I THOUGHT the string would look like this: <asp:SqlDataSource ID="SqlDSBooks" runat="server" ConnectionString="<%$ ConnectionStrings:csK2Reader %>" SelectCommand="SELECT * FROM [Books] ( If @Type <> "" then WHERE ([Type] = @Type)) ORDER BY [SortDate] DESC"> But it doesn't seem to want to work. I get a "server tag is not well formed" error.
View Replies !
View Related
Simple SQL Query -- Perhaps You Can Help
I hope it's considered appropriate to post a SQL query question here; it's not I'll gladly post this question elsewhere. That having been said, I've run into a simple but quite tricky SQL query and was wondering if the community might be able to help. Here's what's going on: I have a "Documents" table. Let's call it DI have a "Benefits" table. Let's call it B.There is a many-to-many relationship between D and B so I have a third table to store the relationships. Let's call that table BD. When I create a document it creates a row in D. Let's call that D1, D2...DN. When I create a benefit it creates a row in B. Let's call that B1, B2...BN When I associate a document to a paritcular benefit, let's say that if D1 and B2 are associated, that I created row B2-D1 in my BD table. Now here's what my challenge is. Suppose I have these entries in my tables: D: D1, D2, D3B: B1, B2, B3 Table BD:B1-D1B2-D1B2-D2 When the user goes to add documents to benefit B1, I want to show the user only documents that are not yet added to B1. In this case, I want to show the user D2 and D3 but not D1 since that one's already added. How do I write a SQL query to do this? Here's what I've been using, but it shows too many results (e.g. included D1, D2, D3) SELECT D.*, BD.*FROM Documents AS d LEFT JOIN rel_BenefitsDocuments AS bd ON d.doc_id = bd.doc_idWHERE (benefit_id <> @benefit_id OR benefit_id IS NULL) Any thoughts?
View Replies !
View Related
Simple Query Help...
I am trying to select players from a database based on the userid not having any user's name in it with an order by ASC. I basically want all the players that haven't been taken. Here is what I came up with and it gives me empty. strSQLA="SELECT UserID, playerName from Allplayers WHERE UserID = '' ORDER BY playername ASC"
View Replies !
View Related
Simple MAX Query?
Hi AllI know that I am supposed to submit a schema of my table, but it is a verybasic one so I'll crack straight on with my query.In essence I have a 3 column table called STOCKTRANS, which consists ofSTOCKCODE, TRANSACTIONDATE and TRANSACTIONTYPE.Each time a user orders a stock item I insert the stock code and the datethey ordered it into this table, egSTOCKCODE TRANSACTIONDATE TRANSACTIONTYPEIVP 1-4-04 1STP 31-6-04 8KGC 8-7-04 6IVP 11-8-04 8etc etcetcWhat I want to create is a simple query that informs what the last orderdate was for a stock code. As you can see from the above example, I mayhave hundreds of the same stock code with different dates so I thought thatthe following query would work:select STOCKCODE, MAX(TRANSACTIONDATE) as 'LastOrderDate'from STOCKTRANSwhere STOCKCODE = 'IVP' and TRANSACTIONTYPE in (1,8)But it doesn't.NOTE: the reason for the transaction types of 1 and 8 is because these arethe types I want. The other types are used for credits, returns, etc.First of all the above, brings me back loads of rows when all I want is:IVP 11-8-04 << this being the last date of order for this stock item.Just as a test I removed the STOCKCODE out of the select and found that Idid get my one liner, but for some reason I was only getting the last datefor transaction types 1 only - not the last date for a combination of 1 and8 transactions.Can you help??Many thanksRgds Robbie
View Replies !
View Related
Simple Query
I know this is super-basic, but I'm a newbie and I can't get it to work...I'm trying to call a stored procedure that has a datetime as one of itsparameters. How the heck do I get a datetime?? I'd even settle for knowing Iwas declaring variables correctly...DECLARE @Date datetime (right?)???EXEC usp_AddRequest 313,'E',@Date,'QUAL'^^^^^ <- this is the parameter that wants to be adatetimeHow do I make Date correspond to an actual date/time? How do I assign it tobe equal to SELECT GETDATE()? Why doesn't SET @DATE = SELECT GETDATE() work?And why the heck is it so hard to find the answers online?? I've Googledendlessly and found nothing...--Christopher Benson-Manica | Jumonji giri, for honour.ataru(at)cyberspace.org |
View Replies !
View Related
Simple Query?
I have a table that looks like this: c1c2 1a 1b 1c 2a 2b 2c 2d 3a 3b 3c 3d 3e I want a result set that looks like this: c1c2c3 1a1 1b2 1c3 2a1 2b2 2c3 2d4 3a1 3b2 3c3 3d4 3e5 Basically, grouping/numbering the rows by column c1. The number of distinct c1 columns and distinct c1,c2 columns is varying.
View Replies !
View Related
Simple Query Help
Hi, I want to write a sql query for an asp page which will display only unique rows from the specified column along with the number of count for each unique row. Example: Table that I want to query Last Name || First Name Gates || Bill Boyce || Mike Gates || Bill Gates || Phil Results I want: Last Name || First Name || Count Gates || Bill || 2 Boyce || Mike || 1 Gates || Phil || 1 Thanks a lot, Heta
View Replies !
View Related
Simple Query
Hi, I am new to SQL and this question may be most easiest to many of you. Here is what I need. I have two identical tables (exactly the same in structure) having a compound primary key with a combination of 3 columns. Can someone give me the most efficient query that fetches all the rows from table1 that are not in table2. Thanks in advance for your help Kevin
View Replies !
View Related
Simple Query
Hi, I have a very simple question: declare @treshold int set @treshold = 10 SELECT dbo.fn_Calc(t.column1) as calc, t.column2 FROM mytable t WHERE dbo.fn_Calc(t.column1) > @treshold I can't think of a way to get rid of the function call in the WHERE clause. Is this actualy a problem ? I mean does realy the function fn_Calc execute 2 times in this statement and isn't this a performance issue then? thanks
View Replies !
View Related
Query Help Please Max() Simple?
This is my query...I am attempting to only return the records for each sales_contact with the greatest issue_id select sc.sales_contact_id , idd.issue_id , sr.code from sales_contact sc , invoice i , invoice_line_item il , sales_region_special_section srss , sales_region sr , issue_date idd where sc.sales_contact_id = i.sales_contact and i.invoice_id = il.invoice and srss.sales_region = sr.sales_region_id and il.issue_date = idd.issue_date_id and srss.invoice_line_item = il.invoice_line_item_id order by sc.sales_contact_id ================ heres some of the result set I want only the records with the greatest id for each unique sales contact... AF85F32E-8E34-4C40-9468-00148A34E903, 41, N AF85F32E-8E34-4C40-9468-00148A34E903, 42, N 5D26328A-192B-4E4E-9B34-010C4E077CF8, 77, N 5D26328A-192B-4E4E-9B34-010C4E077CF8, 70, N 5D26328A-192B-4E4E-9B34-010C4E077CF8, 34, BC B44C914E-6001-40CE-8AB6-0126BD572D45, 25, NW B44C914E-6001-40CE-8AB6-0126BD572D45, 26, NW B44C914E-6001-40CE-8AB6-0126BD572D45, 24, NW B44C914E-6001-40CE-8AB6-0126BD572D45, 28, HC B44C914E-6001-40CE-8AB6-0126BD572D45 , 28, NW this would be an ideal result set using the data above...note there are situtations where there are n* for a greatest issue id. AF85F32E-8E34-4C40-9468-00148A34E903, 42, N 5D26328A-192B-4E4E-9B34-010C4E077CF8, 77, N B44C914E-6001-40CE-8AB6-0126BD572D45, 28, HC B44C914E-6001-40CE-8AB6-0126BD572D45, 28, NW thanks in advance for your help.
View Replies !
View Related
Simple Query
This should be easy, I'm just having a brainfart at the moment, can't remember how to do this: Say I have a bunch of records in a table, with an ID field as Key. I want to return the count of times each ID shows up, so for the following example data: Code: ----- | ID | ----- | 1 | | 2 | | 1 | | 4 | | 1 | | 4 | ------ Would return something like: Code: ---------------- | ID | Count | ---------------- | 1 | 3 | | 2 | 1 | | 4 | 2 | ----------------- This should be obvious but for some reason I can't see it. When this is done I'm going to join in another table to get a name based on the ID with the highest count. I believe it's faster to do a TOP 1 here rather than after the join, but I want to verify that while I'm at it also.
View Replies !
View Related
Simple Query
OLD_TABLE CustomerPost_ClosestStore1_ClosestStore2_ClosestStore3 00501_____9339_____9193_____9445 02151_____9161_____9838_____9185 02917_____9788_____9105_____9626 06443_____9644_____9102_____9286 43434_____9258_____9496_____0 NEW_TABLE CustomerPost_ClosestStore1_ClosestStore2_ClosestStore3 00501_____9339_____9193_____9445 02151_____9161_____9838_____9185 02917_____9788_____9105_____9626 06443_____9644_____9102_____9286 43434_____9258_____9496_____1111 (end result) FINAL_TABLE 43434_____9258_____9496_____1111 I have two tables ... I am trying to get only the rows that are different.
View Replies !
View Related
Simple SQL Query
Hi folks, I am a complete newbie to SQL. I have a simple query to make in SQL, but I'm not being able to construct the statement properly. I've already tried googling this info, but with little luck. If someone could help me here, I'd be very thankful. The problem: I have a table with a list of questions. All questions have a serial number. The query has to return whether a particular question is the last one in the table or not (according to serial no.) Logically, this is the query - Code: select islast = 0 if count(*) from question where serialno > $serial != 0 else select islast = 1; The '$serial' part will get replaced dynamically before query execution through another program. Any idea how to code this in valid SQL? I would like to make it a simple statement and not a stored procedure. Thanks.
View Replies !
View Related
Simple SQL Query Help
Hi, This is probably a simple SQL statement question, so please bear with me. Basically I have a CustomerMaster with the following fileds 1) CustomerID 2) CustName 3) Address 4) ResTelNo I want retreive the CustName,Address and ResTelNo if the ResTelNo has occured in the table more than twice. Could someone please help with this. I would like to use the same query in MS Access as well. Thanks in advance for your help.
View Replies !
View Related
Simple Sql Query..help Please
Hey.. hope someone can help, i desperatly need some assistance. I have a few query issues but first things first.. one is that i have a table of messages and users having an online conversation, so fields are msg id, subject, topic, message, user, reply to and time it was sent. Im trying to do a query that will tell me which user sent the most messages, ive tried using count and stuff like that but not really getting anywhere. It will basically have to count each time a user has spoken and then give me the name of the user that has sent the most messages, ive been playing around with stuff like SELECT Count(*) AS Expr1 FROM Table1 WHERE User='andro8472' OR User='bumies'; That will count the times those users have spoken but cant get further any help would be greatly appreciated really stuck at the mo.. thanks
View Replies !
View Related
What Should Be A Simple Query
I'm having a bad day as I just cannot get a query to work and its doing my head in and it should be a simple query. I'll try and explain what I need. Have a simple query with one join, this is it so far: SELECT DISTINCT Replace(StaffName,'''''',' ') AS StaffName,OutReason,OutStartDate ,OutEndDate,OutStartTime,OutEndTime,OutID FROM vwOutOfOffice LEFT OUTER JOIN vwStaffList ON OutUser=StaffID WHERE OutComplete=0 What I'm having trouble with adding to the WHERE is as follows, I need a list of Staff who are out of the office based on the various criteria: Example Current date=29/02/2008 Current time=14:00 Start date---End Date----Start Time--End Time--Should Appear 27/02/2008--28/02/2008--09:00------17:00-----No (because of date) 28/02/2008--03/03/2008--08:00------17:00-----Yes 28/02/2008--29/02/2008--17:00------17:00-----Yes 29/02/2008--29/02/2008--12:00------14:00-----Yes 29/02/2008--29/02/2008--14:30------17:00-----No (because of time) 02/03/2008--02/03/2008--08:00------10:00-----No (because of date) There may be others I've missed but as long as the dates combined with the times match correctly I need the records to appear. Please help before I end up putting my head through the monitor.
View Replies !
View Related
Help On Simple Query
What is wrong with the following code declare @today datetime set @today = getdate() DECLARE @l_PPA_CONTACT_VALUES_Tbl TABLE( PARTY_ID NUMERIC(10,0), CONTACT_VALUES VARCHAR(7000) ) INSERT INTO @l_PPA_CONTACT_VALUES_Tbl SELECT PARTY_ID ,CONTACT_VALUES FROM PEGASUS.PEGASUS_AP_GET_PARTY_CONTACTS_TABLE_FUN(NULL, NULL,0, NULL, 'Business', 'Yes', 1, @today, NULL, 'ACTIVE', 0) select ppaCon.PARTY_ID, (SELECT TOP 1 VALUE_TEXT FROM PEGASUS.PEGASUS_AP_SPLIT_FUN(ppaCon.CONTACT_VALUES, 0) WHERE VALUE_TEXT LIKE 'Business Phone:' ) OfficePhone from @l_PPA_CONTACT_VALUES_Tbl ppaCon right join PEGASUS.PARTY_PAIRS ppa on ppaCon.PARTY_ID = ppa.PPA_ID I am getting the following error Msg 170, Level 15, State 1, Line 15 Line 15: Incorrect syntax near '.'. and the error is poiting to the portion of code PEGASUS.PEGASUS_AP_SPLIT_FUN(ppaCon.CONTACT_VALUES, 0) THanks
View Replies !
View Related
How To Do This Simple Query ?
I have a table with these columns, Warehouse, Items ABC, 2 CDEF, 0 Something, 10 Something 0 I want to get Warehouse and count of Items grouped by Warehouse. Omit all Items that have count greater than 2. Show only groups having ferwer than 2 item counts and have the result displayes in descending order of Items count.
View Replies !
View Related
How To Do This Simple Query?
Hi, I have two tables with a one to many relation. Tbl 1 - POs (stands for purchase orders) Tbl 2 Invoices Each is linked by a POID which a varchar field. there is one POID which can have none to several Invoices I need to work a query to work out the total money left outstanding from the PO's. I thought the easiest way would be to SUM the subtotal field in the POs tbl, and from that minus off the SUM total of the InvoiceSubTotal from the Invoices tbl. This would give me a figure which is what was left outstanding.. pretty straight forward. however every attempt I've had so far is not grouping the Invoices together correctly for each PO so I'm getting incorrect totals. Here's my first attempt: Code Snippet SELECT SUM(dbo.Suppliers_POs.SubTotal - dbo.Suppliers_Invoices.InvoiceSubTotal) AS TotalOutstanding FROM dbo.Suppliers_POs INNER JOIN dbo.Suppliers_Invoices ON dbo.Suppliers_POs.POID = dbo.Suppliers_Invoices.POID Although that returned a result it wasn't correct. What seems to be happening is that for each PO with a matched invoice it gets the SubTotal and then get the InvoiceSubTotal and gets a figure.. if there is another invoice for the same PO.. it does the same thing.. So lets say I have a PO for £50,000 There are three invoices on the system for £10,000 each (Therefore there is £50,000 on the PO, £30,000 on the invoices.. I should be left with £20,000) Instead it gets the first invoice.. see the PO for £50,000 and minus' the £10,000 giving £40,000 It then does the same for the other two.. So I get a figure of £120,000!!! How do I get around this? Thanks for any help you guys can offer..
View Replies !
View Related
A Simple Query
Hello there, this is my first time here,please tell me if I'm posting in the wrong place. well I have a table with three columns: nb,date and place; a query like (select * from table where date<'3/19/2008 11:00:00' and date<>3/19/2008 8:00:00' ) returns: nbr date place 11 '3/19/2008 08:05:00 aa 11 '3/19/2008 08:06:00 aa 11 '3/19/2008 08:07:00 aa 22 '3/19/2008 08:08:00 ab 22 '3/19/2008 08:09:00 ab 11 '3/19/2008 10:00:00 aa 11 '3/19/2008 10:05:00 aa My prob is that I don't need all those records: the first three records for me refer to the same object so I want just one of them, same for the 4th and 5th records I just want one, and for the last 2 records, so I need a query that returns 11 '3/19/2008 08:05:00 aa 22 '3/19/2008 08:08:00 ab 11 '3/19/2008 10:00:00 aa
View Replies !
View Related
Need Help With A Simple Query
Hi Everyone: I am new to SQL, and I would like to request if someone could provide me with a query that could do a find and replace in a column in MSDE. I have an image path column in a table, the current image path is set to /images/xxxx.gif I would like to add another folder so the image path looks like this --> /images/imagesA/xxxx.gif The problem is i have 4500 records to update, so I cannot do this manually, so my question is can someone provide me with a query that can do this find and replace, i guess in this situation you are finding /images and replacing it with /images/imagesA Please advise. Thanks. It would be nice if you can send me this query to my email. My email address is aleemmansoor@hotmail.com
View Replies !
View Related
Need Help On Simple SQL Query
Hi I am just starting out on sql programming. I have one table with three columns Item Name | Price |Date Item1 | 44 |25-Jan-08 Item1 | 45 |26-Jan-08 Item1 | 43 |27-Jan-08 Item2 | 21 |26-Jan-08 Item2 | 34 |28-Jan-08 Item3 | 91 |27-Jan-08 Item3 | 98 |29-Jan-08 I want to pick latest price of all items and produce a result as below Item1 | 43 |27-Jan-08 Item2 | 34 |28-Jan-08 Item3 | 98 |29-Jan-08 Please help me on this Thank You -Jag
View Replies !
View Related
Simple SQL Query
I have a teams table with an id col (primark key) and name col. I also have a fixtures table. its has an Id, hometeam, awayteam and date cols. I would like to use the Pk of the Teams table as a foreign key in the fixtures table for both the hometeam and away team cols. How could I write the SQL to get a list of fixtures for a specific team given the ID of the team. Many thanks for your help
View Replies !
View Related
A Simple Query...plz Help
Hi All, The following table is entitled "class". ID Number NameJoin DateSex 101 Jason01/02/1996M 117 Robert06/25/1999M 113 Doug08/12/1999M 161 Marian07/30/1998F Please let me know the SQL queries for the following questions for the above table: 1)Write a Select statement that selects the persons whose Type is "M" and who have joined in the last four years and place the result in an array. Today's date is 12/31/1999. 2) Write a Select statement that selects the persons who do not have unique ID Number and place the results in an array. 3) Write code to sort the array by Name + Join Date. Assume that the array has already been created and is sorted in the same manner as the table above. The Join Date is of type smalldatetime. The Name field should be sorted case insensitively. Thanks for your help.
View Replies !
View Related
Simple Query
I have a table like create table sample (Column1 , Column2 int) I want to select say 3 or 4 Column1's for each Column2 with out using a cursor. Can u help
View Replies !
View Related
Help! Should Be A Simple Query
Hi I've got what should be a simple query but I'm not sure how to write it. I have a table which holds employee assignments to positions, which holds historical data. Eg: ID EmployeeID StartDate PositionID --- ---------- --------- ---------- 1 7663 23/1/2007 234 2 7663 28/6/2007 272 3 7663 1/02/2008 983 4 81212 2/03/2008 2888 Now, what I'm after for each employee is their current position based on the highest "StartDate" for that employee. So from the above table I want the results: 3 7663 1/02/2008 983 4 81212 2/03/2008 2888 Can anyone help? Do I need a Group By? That clause always confuses me!!! Thanks!!!!
View Replies !
View Related
Simple Query?
Hello, You probably seen this Q before but I have no idea what to search and and therefor any direction would be appreciated. I have three columns table, two are int and one is datetime (for sorting). I would like to query all values witch are unique within the two integers, however, in some cases data looks like this: int1 = 1 int2 = 2 and another record like: int1 = 2 int2 = 1 this pair should be considered as a duplicate and second record should not come with the results set. Any suggestions?
View Replies !
View Related
I Need Some Help With This Simple Query !!
Hi, I have this query: SELECT ('Section : ' + F.Section + ' ' + (SELECT S.SectionName FROM SFM_Section AS S WHERE S.Company = F.Company AND S.Department = F.Department AND S.Section = F.Section ) ), F.Variety, F.Category, isnull(SUM(F.AreaCutCurrent), 0) AS AreaCutCurrent, isnull(SUM(F.TonnageCurrent), 0) AS TonnageCurrent, isnull(SUM(F.YieldCurrent), 0) AS YieldCurrent FROM SFM_Field AS F WHERE F.CropYear = 2007 and ActiveFlag = 1 and Section = 04 GROUP BY F.Company, F.Department, F.Section, F.Variety, F.Category ORDER BY F.Section, F.Variety, F.Category that returns me the following results: Section:04 Region Haute|M0052/78|R07|1.84 |137.64 |74.804 Section:04 Region Haute|M0695/69|R01|37.71|2817.65|434.009 Section:04 Region Haute|M0695/69|R02|35.08|2282.33|523.234 Section:04 Region Haute|M0695/69|R05|21.2 |1563.01|147.579 Section:04 Region Haute|M0695/69|R09|6.52 |484.39 |74.293 Section:04 Region Haute|M0695/69|R11|0 |0 |0 Section:04 Region Haute|M1397/86|R04|8.35 |793.61 |190.141 Section:04 Region Haute|M1400/86|GS |18.03|2093.91|116.135 What should I do if I don't want the records that the sum is equal to 0 to appear in my results? (Like the 3rd row from the end) Thanks for your help
View Replies !
View Related
Simple Query Help
How do I retrieve all rows from a middle_name column that have a character length of <= 2. This table is populated with middle names and middle initials. I want to isolate the middle initials only.
View Replies !
View Related
Simple Query Which I Am Not Able To Understand
Hi,I have a float column in the database. When ever, I enter a value into the table, the values are rounded. Suppose I execute the following script: create table tblamount( flttotal_amount float)insert into tblamount values (0.00)insert into tblamount values (0.00)insert into tblamount values (0.00)insert into tblamount values (0.00)select * from #tblamount returns the following values:0000 but I want the ouput with the values 0.00 that I entered in the DB. Can u pls help me out with this?
View Replies !
View Related
Need Help With A Simple SQL Server Query
I would like to insert 17 records into a table just by querying another table using a subquery. I remembered I did this successfully once before in Oracle, but not sure if it can be done in SQL Server.insert into [MyK].[dbo].[products] (product_name,LMVERSION) values (SELECT PUBLICNAME, LMVERSION FROM [LICENCEMANAGER].[dbo].[PRODUCT] where publicname is not null and register is not null) I get this error:Msg 156, Level 15, State 1, Line 2Incorrect syntax near the keyword 'SELECT'.Msg 102, Level 15, State 1, Line 2Incorrect syntax near ')'.Any suggestions on how to succeed with this?
View Replies !
View Related
Simple Search Query
Hi, I'm writing small search engine for my page. I need SQL query that could do this: Source: tblColours ------------ Red GreenRed White Red Yellow Blue Green Yellow RedF Search string: Red Required results: Red White Red Yellow RedF As you can see I need all occurrences of word Red and word Red* but I don’t need *Red or *Red* so I can't use LIKE %Red% :(. P.S. Sorry for my English. Fizikas.
View Replies !
View Related
A Simple Strange Query..........
I am having in writing a simple select command........here's My ProblemI am using the ASP SQLDataSources in VS2005.... and my need is that i need to show Products details in a Gridview...... Actually through QueryString a StoreID is being fetched..... and the Products under those StoreID are shown..... if there is nothing in query string then it should show all the results... ........ It means that my querystring should be something like thisselect * from tblProducts where StoreID = <xyz>and <xyz> should be some thing that could show all the rows in that table ........ i mean that it should show all the possible results that can be shown through...select * from tblProducts
View Replies !
View Related
Help With Simple(ish) Select Query?
Hi I Have the following table SequenceNumber___TypeID8_________________IMG7_________________IMG6_________________IMG5_________________IMG4_________________IMG3_________________IMG2_________________FLP2_________________IMG I want to pull the data out in the following format, SequenceNumber___TypeID8_________________IMG2_________________FLP This basically shows the highest SequenceNumber of each TypeID, I've tried many different SQL queries but I can't seem to get it! Any ideas? Thanks
View Replies !
View Related
Simple Query Question, Please Help
Table{ id, int (identity) id2, int ...} I need to insert a row in a table and make id2=id it is actually quite easy to do it in 2 seperate queries, however, i wonder if there is a way to do it in one query with system functions. I am quite new to MSSQL, hope somebody can give me a hand. Thanks
View Replies !
View Related
Need Help With Simple Select Query
This is the query I wrote, but it only selects the personel who have Workgroups and Access Groups assigned to them but I want to show all the employies and if they don't have Workgroups and Access Groups assigned to them then show empty cells on DBGrid... and I know the red part is the problem but I could not build up the logic to select the matching records and empty records at the same time... Thanks in advance SELECT DISTINCT CARD.LNAME, CARD.MNAME, CARD.CNUM, CARD.CNAME, C_GRP.NAME, AGRECS.AGNAME, AGRECS.SITENAME, WorkGroups.WGName FROM CARD INNER JOIN PersonelWG ON CARD.CNUM = PersonelWG.Cnum INNER JOIN C_GRP ON CARD.GNUM = C_GRP.NUM INNER JOIN WorkGroups ON PersonelWG.WGID = WorkGroups.WGID INNER JOIN AGRECS ON CARD.ACGRP = AGRECS.AGNUM By the way this is my query structure:
View Replies !
View Related
Simple SQL Query Problem - Please Help!!!
Hi, I am a beginner and I am faced with a SQL problem.I have a SQL table named: tblCompanyActivities (what you see here)The column named companyID is the FK of a table named tblCompanyThe column named activitiesID is the FK of a table named tblActivities ID companyID activitiesID 1 1 1 2 1 2 3 1 3 4 1 4 5 2 1 6 2 2 7 2 6 8 2 7 All I want to to is to return the companyID of the company that's field of activity is 2 AND 3.So I want the query to return 1. But the following query returns nothing: SELECT companyIDFROM tblCompanyActivitiesWHERE (activitiesID = 2) AND (activitiesID = 3) Why and what can I do to solve this?
View Replies !
View Related
Simple Query Question
Ok. Call me dumb, but why is this occurring. Table firstv has 303,000records, table lla has 10,000 records. When I run this query though:SELECT IsNull(lla.voy, '') as voy, IsNull(lla.poe, '') as poe,IsNull(firstv.ocean, '') as ocean,IsNull(firstv.car, '') as car, IsNull(firstv.equipment, '') asequipment FROM LLA INNER JOIN firstv ON lla.voy = firstv.voy ANDlla.poe = firstv.poe ORDER BY lla.voyI get 721,000 records back. Maybe I'm just too tired...but why is thishappening? Where is the logical error?
View Replies !
View Related
Question About Simple Query..
How are you ? Please give me an advice :)It's been bothering me for three days. I'm new SQL user.I have the following table, which has name, address, city,state,zipcode, and phone number.kim 3134 n. chatham ellicott city md 21042410-222-2222justin 3134 n. chatham rd. ellicott city md 21042410-222-2222hong 4343 antonio ln. ellicott city md 21042555-341-3412woo 1123 cedar ln. columbiamd21044 410-111-1358The problem is that the table should not contain the same phonenumber.Phone number 410-222-2222 is duplicated.How can I erase that extra data, and get the table like this ? :kim 3134 n. chatham ellicott city md 21042410-222-2222*******************the data that has same phone number isgone*****************hong 4343 antonio ln. ellicott city md 21042555-341-3412woo 1123 cedar ln. columbiamd21044 410-111-1358First, I used this query, but it turned out all of my data was gone. :(delete FROM address WHERE exists (select * from address where address.phone = address.phone);Please help !
View Replies !
View Related
Reasonably Simple Query Question
I'm an SQL beginner and this is driving me nuts as it seems simple enoughbut I can't figure it out.I have a table that looks like:ID: intMajorVersion: intMinorVersion: intContent: ntextThe ID is not the table key - different rows can have the same ID.The MajorVersion and MinorVersion columns together make up a version number.Say if a row represented version 1.8 of that ID, MajorVersion would be 1 andMinorVersion 8.All I want to do is query for ID and Content for the highest versions ofeach ID. I tried using GROUP BY but I can't do that because I can't includeContent in the SELECT then.Am I going to have to just query for the ID and then do a join to get theContent?Thanks for any helpChris
View Replies !
View Related
Simple Query, But Can't Figure It Out
I'm sure this is simple -- I'm just spacing it today. Assume the following:freq fruit---- ----10 apple5 apple7 banana6 pear3 pear2 orange8 orange13 kiwiHow do I find the highest [freq] for each [fruit] all at the same time, e.g.:10 apple7 banana6 pear8 orange13 kiwiThanks in advance.Mark D.
View Replies !
View Related
|