Simple But Complex Report
Jul 20, 2005
Hi All
Wondered if you could help.
Basically I have 2 tables that contain all the data I want for my report,
but I need to put it in a particular way and I need to display it in an ASP
page so my queries got to be manual rather than an MS Excel/Query 'munge'.
To be honest, the report itself is very basic, so hopefully my ramble will
make sense. I need to report that shows 6 columns at best, 4 columns if
it's easier. Report looks like the following:
Account Code - standard text field
Account Name - standard text field
Turnover (Year to Date) 2002 - standard decimal number (single??) field
Turnover (Year to Date) 2003 - standard decimal number (single??) field
(not vital, but would be nice)
Deviation as a straight figure between what the 2003 turnover figure is
against the 2002 figure - ad hoc calc field
Deviation as a % between what the 2003 turnover figure is against the 2002
figure - ad hoc calc field
My table structure is as follows:
TABLE 1 - ACCOUNTS
This contains all of the account codes (PK) and names as ACCOUNTID and NAME
respectively. It also contains a field called LEDGER which I would need to
use in a Where clause to set this to 1 (1 = sales and 2 = purchases).
TABLE 2 - ACCOUNTBUDGETS
This contains the Turnover details and is linked to the ACCOUNTS table by an
ACCOUNTID (FK??). This table contains a TURNOVER field for the actual
turnover amount, a PERIOD field for the months of a year (eg, 1 - 12 - that
being Jan to Dec) and a YEAR field for the relevant years.
In this ACCOUNTBUDGETS table it basically keeps a line-by-line record of
each turnover for each period and year for each account code. As you
probably would with any transaction line storing table.
An important part of this is that I want to show all of the Account codes
and names that relate to LEDGER=1 even if they have no entries in the
ACCOUNTSBUDGETS table. The reason being is that I want to be able to show
that an account might not have traded for 2002 and therefore their 2003 Year
to date might be really good cos they've sold loads in 2003.
So the final part is that I need summarise the Year to date figures next to
each account code and name. To do this I need to take what the month number
is now (eg, Dec = 12) and summarise all the turnover figures for 2002 upto
12 and then all the turnover figures for 2003 upto 12. If you can imagine
when this report is run in March the report would summarize from 1 to 3
rather than 1 - 12 in the last examples.
The nice bits on the end would be that they would give 2 different calcs
against what the 2 turnover figures stated.
The result should be something like the following:
December Turnover YTD
Deviation
Acc No: Account Name 2003 2002 £
%
A001 Alpha Motor 9,250 5,398 3,852
71%
A003 A J V Secure 0
94 -1,294 -100%
A004 Aye Gee 0
39 -4,239 -100%
A007 P H Allin 2,235
08 -1,973 -47%
Any ideas??
Rgds
Robbie
View 3 Replies
ADVERTISEMENT
Feb 1, 2004
HI FRIENDS,
I HAVE ONE FOLLOWING TABLE
CREATE TABLE1(
COL1 VARCHAR(400))
I INSERTED ONE ROW. NOW LENGTH OF COL1 IS 350 CHARACTER.
WHEN I FIRED QUERY "SELECT COL1 FROM TABLE1"
I GOT ONLY FIRST 256 CHARACTER.
I WANT TO RETRERIVE FULL CONTENT OF "COL1" .
PLS GUIDE ME , HOW SOLVE THIS PROBLEM.
THANKING YOU,
DHIRAJ
View 2 Replies
View Related
Nov 23, 2006
Here is my data
------------------------------
BookName | Price
Book 1 | 75
Book 2 | 100
Book 3 | 45
Book 4 | 10
I want to make a report eg:
Category | Total
>= 75 | 2
25 - 74 | 1
< 25 | 1
View 1 Replies
View Related
Feb 14, 2008
Hi Everyone,
I need to create a grand total field that uses aggregated data from the footer of each group. Any ideas on how I can create the grand total Productivity level in RS 2005? I cannot retrieve the value in the table textbox since it's not in the same group. Thank You
Team Leader: Sam Doe
Days in Dept Productivity Level
------------------------------------------------------------------------------------------------------------------------
Service
Agent 1
Agent 2
Agent 3
Agent 4
Total for Service: 124 1
Parts
Agent 5
Agent 6
Agent 7
Total for Parts: 54 3
------------------------------------------------------------------------------------------------------------------------
Grand Total: 178 (1* 124/178) + (3* 54/178) = 1.63
View 3 Replies
View Related
Dec 7, 2007
Hi Everyone,
I'm currently working on a report that is using the matrix tool. But unfortunately I can't create the required report layout as shown below.
Student Name
Additional Information
TERMS
SUBJECT DETAILS
English
Mathematics
History
Term1
Term2
Term3
Quiz
Project
Final Exam
Quiz
Project
Final Exam
Quiz
Project
Final Exam
John Smith
Adviser
Mr. Johnson
Ms. Brown
Mr. Clark
89
79
80
88
80
87
85
89
90
Section
Section 1
Section 2
Section 2
School Year
2007-2008
2007-2008
2007-2008
Michelle Park
Adviser
Ms. Brown
Mr. Clark]
Mr. Johnson
87
78
85
78
85
86
89
90
94
Section
Section 3
Section 2
Section 1
School Year
2007-2008
2007-2008
2007-2008
Based on our analysis, this report seems requires 2 matrices to be joined together. The first one is the TERMS section and the other is SUBJECT DETAILS.
TERMS with dynamic data values such as Term1, Term2 and Term3 contains static row information such as Adviser, Section and School Year that is group by Student Name.
SUBJECT DETAILS with dynamic data values such as English, Math and History contains static columns such as Quiz, Project, Final Exam group by Subjects and Student Name.
How can we join two matrices in one report? Can someone help me on this?
Please bare with my sample matrix layout.
Thank you in advance.
-lia-
View 1 Replies
View Related
Apr 16, 2007
Hi all,
I had developed all my reports using CRXI and stored procedures of MSSQL 2000. Now I am migrating from CRXI to SSRS. But i have a problem because of my report stored procedures. These stored procedures are complex and nested. When i try to use procedures in a report, it gives a error. When i comment out my EXEC line in my procedures, it goes OK.
Please help me to do this ?
View 1 Replies
View Related
Nov 12, 2003
I have web forms with about 10-15 optional search parameters (fields) for a give table. Each item (textbox) in the form is treated as an AND condition.
Right now I build complex WHERE clauses based on wheather data is present in a textbox and AND each one in the clause. Also, if a particular field is "match any word", i get a ANDed set of OR's. As you can imagine, the WHERE clause gets quite large.
I build clauses like this (i.e., 4 fields shown):
SELECT * from tableName WHERE (aaa like '%data') AND (bbb = 'data') AND (ccc like 'data%') AND ( (xxx like '%data') OR (yyy like '%data%') )
My question is, are stored procedures better for building such dynamic SQL clauses? I may have one field or all fifteen. I've written generic code for building the clauses, but I don't know much about stored procedures and am wondering if I'm making this more difficult on myself.
View 7 Replies
View Related
Jan 3, 2008
Hi,
I have a simple report written in SQL and I only want to show the TOP (2) records by date for each branch...
When i try and use the TOP (2) command it gives me only the very first 2 records...
my code is as follows:
SELECT REPLACE(CONVERT(VARCHAR, FilteredNew_Visit.new_startutc, 3), '/', '/') AS new_startutc, REPLACE(CONVERT(VARCHAR,
FilteredNew_Visit.new_endutc, 3), '/', '/') AS new_endutc, FilteredAccount.accountid, FilteredAccount.new_branch, FilteredAccount.name,
FilteredAccount.new_versionmbaname, FilteredAccount.new_versionwename, FilteredAccount.new_primarytsmname, FilteredNew_Visit.new_typename,
FilteredNew_Visit.new_name, FilteredNew_Visit.new_endutc AS Expr2, FilteredNew_Visit.new_startutc AS Expr1,
FilteredNew_Visit.new_accountid
FROM FilteredNew_Visit INNER JOIN
FilteredAccount ON FilteredAccount.accountid = FilteredNew_Visit.new_accountid
ORDER BY FilteredAccount.name, Expr1 DESC
can anyone help...i dont think i have explained this very well..
sorry total newbie
View 14 Replies
View Related
Apr 13, 2008
I have a report with a table and three columns. Whenever the data in one of the columns cannot fit on a single page it continues on the next page BUT, there is no header on the next page and the data in the other two columns repeats itself on the next page. (This behavior happens when I export to PDF)
Is this a known issue? I have tried every setting I could think of.
Thanks
View 7 Replies
View Related
Apr 2, 2007
Hi all, I've been building a set of traffic based reports on our website and I've run into a strange problem.
The reports are pretty basic, and up till now I've been really impressed with RS overall.
Recently I've added a StartDate and EndDate and since then the performance has gone from ~10 secs to ~10 minutes.
I've taken a really simple query from my reports. Running this query in Management Studio on the same data returns in less than a second. When its run from a test report with nothing else in it it takes ~1 minute. Even stranger when I run the same query with the same values for parameters inside of RS in the data view it takes less than 1 second. ARG!
SELECT COUNT(DISTINCT SessionID) as Occurences
FROM WebAppSummary
JOIN WebAppLocalizations
ON WebAppSummary.ClientIp = WebAppLocalizations.ClientIp
where FirstTime BETWEEN @StartDate AND @EndDate
The last line that was just added is this part:
where FirstTime BETWEEN @StartDate AND @EndDate
So whats going on here? Is this a really poorly performing query that management studio is optimizing but RS isnt? Is RS messing up the databind and getting a bunch of DSs instead of just one?
View 1 Replies
View Related
Jun 18, 2007
Experienced memebers,
I have what should be simple question about related tables in a dataset and using those fields in a report. Here is my simple design.
Order Header -> Line Item -> Line Discount -> Discount Table
Now when designing this report I cannot seem to access the related discount records for the line item. (as more than one can be applied) Every time I try to drag an field from one of the tables in the dataset to my report it automatically adds "First()" onto the field value expression. This seems to work fine for the order header, but doen't even come close to getting the right discount on the line item? I basically need to pass through the Line Discount table to get to the discount name field to put on the same line as my line item data on the report.
I have looked and googled for for an example on this, but have come up short. Can anyone point me in the right direction?
Thanks,
Chris
View 5 Replies
View Related
Apr 22, 2008
So, here is my expression that I use in a textbox on the site header. In the report it just returns error... any ides?
="Wareneingangsübersicht" + " " + today() + " / " +
iif(datepart("WeekdayName",dateadd("d",1,today()))= "Samstag", DateAdd("d",3,today()), DateAdd("d",1,today()))
View 5 Replies
View Related
Feb 1, 2007
I've been running around in circles all afternoon trying to create one simple report using Reporting Services (with latest SP2 installed) and SharePoint 2007. To the best of my knowledge, I have everything configured correctly:
When I access http://<server>/ReportServer, I see the server name of my SharePoint site.
When I click on the name of my SharePoint site, it shows me the directory structure I have created within my SharePoint Site
When I drill down in the directory, I can ultimately see the forms I created in my forms library (created via InfoPath 2007).
The next step is to create one simple report from the data in one of these forms libraries and a report on all the items within a form library. I'm stuck at the first step of creating a report, namely what to enter as the Data Source and the connection string. With a SQL database this isn't an issue.
How does one create a data source that will allow reporting over SharePoint content with the setup described above? And, if you have information that is found in the SQL Books Online, please be kind and post links so others know where to find this information.
View 5 Replies
View Related
May 26, 2004
Hey,
I have MS SQL database.
I have procedure:
code:--------------------------------------------------------------------------------
CREATE PROCEDURE dbo.Reg_DropTable
@ModuleId varchar(10)
AS
declare @TableName varchar, @kiek numeric
set @TableName = 'reg_'+@ModuleId
begin
DROP TABLE @TableName <- HERE I GOT ERROR
end
GO
--------------------------------------------------------------------------------
I got error when using variable with tables names.
How to do this?
Ps. Number is send to this function and it must drop table with name Reg_[That number]
View 1 Replies
View Related
Feb 21, 2007
I am receiving funny results from a query. To simplify, I have 2 tables (todayyesterday). Each tbl has the same 8 columns. My query joins the two tables then looks where either of two columns has changed. What is happening is that when checking one of the columns it seems as though sql is flipping the column, causing it to be returned in error.
result set
colA colB colC colD colE colF colG colG (from yesterday)
1 1 a b c d e m
1 1 a b c d m e
So what's happening is that the record above is actually the same record and should not be returned. There is a daily pmt column that changes but I am not using that in the query. Aside from that the two records are identicle.
Any help is appreciated.
View 7 Replies
View Related
Aug 19, 2006
Hi,
I have the following situation (with a site that already works and i cannot modify the database architecture and following CrossRef tables -- you will see what i mean by CrossRef tables below)
I have:
Master table Hotel
table AddressCrossRef (with: RefID = Hotel.ID, RefType = 'Hotel', AddrID)
joins
table Address (key = AddrID)
table MediaCrossRef (with RefID = Hotel.ID, RefType= 'Hotel', MediaID)
joins
table Media (with MediaID,mediaType = 'thumbnail')
foreach hotel, there definitely is a crossRef entry in AddressCrossRef and Address tables respectively (since every hotel has an address)
however not all hotels have thumbnail image
hence i have hotel inner join AddressXReff inner join Address ..... however i must have
left outer join mediaXref left outer join media
the problem is that if there is no entry in Media or mediaXref, I don't get any results
i tried to get over it by using
where (media.mediaTyple like 'thumbnail' or media.mediaType is null)
but then i started getting multiple results for each hotel because media's of type movie or full_image or etc... all got returned
any clue?
thanks
View 5 Replies
View Related
Apr 26, 2006
Hello,
Lets look at this table :
CREATE TABLE [dbo].[TableHisto](
[Id] [int] NOT NULL,
[Week] [nvarchar](50) COLLATE French_CI_AS NULL,
[Project] [int] NOT NULL
) ON [PRIMARY]
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Identifiant d''enregistrement' ,@level0type=N'SCHEMA', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'TableHisto', @level2type=N'COLUMN', @level2name=N'Id'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Date de l''enregistrement' ,@level0type=N'SCHEMA', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'TableHisto', @level2type=N'COLUMN', @level2name=N'Week'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Projet de référence' ,@level0type=N'SCHEMA', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'TableHisto', @level2type=N'COLUMN', @level2name=N'Project'
It is a table where i store projects week reports.
I want to make a request to display a table with project ID in Row, Weeks in columns and either TableHisto.id or Null value in cell.
I use SQL 2005. Thanks for any help
View 9 Replies
View Related
Jun 16, 2006
SQL server 2005 express reporting problem.
error message:
This feature "remote access to report data sources and/or the report server database" is not supported in this edition of reporting service
I got this error message when I try to connect to database hosted in another PC running SQL server 2000.
Is it true that SQlL server Express can only use Local Database Engine to host the database?
View 5 Replies
View Related
Sep 3, 2006
I need some help on how to structure a sql statement. I am creating a membership directory and I need the stored procedure to output the Last Name, First Name (and if married) Spouse First Name. Like this Flinstone, Fred & Wilma All members are in one directory linked by two fields. [Family ID] all the family members have the same family id and then there is a Family position id that shows if they are the Husband, Wife or Kids. I have no problem with this part select (LastName + ',' + FirstName) as Name, [Phone 1] as Phone, [Unit Name] as WD, [Street 1] as Street, SUBSTRING(City,1,3) as City, SUBSTRING(Postal,1,5) as Zipfrom Membership Where [HH Order]=1 Order By LastName ASC Could someone help me on how to display the " & Spouse FirstName " as part of the name field only if there is a spouse [HH Order]=2 for the current [Family ID]????
View 6 Replies
View Related
Nov 13, 2006
I need to get multiple values for each row in a database, then do a calculation and insert the calculation and the accountnumber related to the calculation the data, into a different column. I get an error trying it this way...there is no real identifier, it is jsut something that needs to get done per row...any ideas on how I can accomplish this?
Declare @NetCommission decimal
Declare @AccountNumber varchar(50)
Set @NetCommission = (select (CommissionRebate * Quantity)
from Account A
Join Trades T on A.AccountNumber = T.AccountNumber)
Set @AccountNumber = (select A.AccountNumber
from cmsAccount A
Join Trades T on A.AccountNumber = T.AccountNumber)
Insert into Transaction
(
Payee
,Deposit
,AccountNumber
)
Values
(
'Account Credit'
,@NetCommission
,@AccountNumber
)
View 13 Replies
View Related
Dec 1, 2006
Hello,
could someone help with this query in a stored proc.?
SET @SQL = 'SET ''' + @avgwgt + ''' = '
'(SELECT AVG(AverageWeight)
FROM CageFishHistory where CageID IN (' + @cagearray + ')
and ItemDate =''' + CONVERT(varchar(23),@startdate) + ''')'
EXEC @SQL
I'm trying to get an average value across dynamically selected rows. (I'm using a list array to deliver the selection to the stored proc). I need to re-use the average value within the procedure,so it's not enough to output it as a column of the resultset - EG. 'Select AVG(AverageWeight) as AvgWgt' . If I take out the @avgwgt line it works fine, but otherwise I'm getting this error:
"Incorrect syntax near '(SELECT AVG(AverageWeight)
FROM CageFishHistory where CageID IN ('."
It may be that I can access a column of the resultset in the rest of the procedure, and that would help avoid the use of pesky apostrophes, but I don't know how to do it.
View 3 Replies
View Related
Jan 6, 2007
I've written a lot of queries in the past, but I'm having a lot of trouble with this one.
View 4 Replies
View Related
Mar 19, 2007
I'm sure there is a way of cracking this, but I can't think of a good solution. Right now I am not happy with the solutions I come up with, one of which takes 4 minutes to run on SQL Server
The scenario: User is presented with search page where one or more search terms can be entered/selected. There are no required parameters. It can be any or all of the possibilities presented. Below is a model of the search parameters presented.
The user will either select to show more options under Profile ABC, or go down to Profile STU or Profile XYZ to show more options, or even select all Profiles and then select from Type 1 and either a. or. b. or. c. or ALL of the above.
I cannot predict what a user will make part of the search query so I have to have a stored procedure ready which can handle any or all of the parameters a user may select.
Am I biting off more than I can chew (it seems so)? Or is there an elegant way of handling the unknown combination of search parameters that a user might throw into my sql query?
I'm running this under ASP 1.0 and SQL Server 2000.
[check to show the options below] Profile ABC
[check to shore more options] Type 1
A. Contains fields for entering another data string and selecting from drop-down boxes
B. ditto
C. ditto
D. ditto
[check to show more options] Type 2
A. Contains fields for entering another data string and selecting from drop-down boxes
B. ditto
C. ditto
D. ditto
[check to show more options] Type 3
A. Contains fields for entering another data string and selecting from drop-down boxes
B. ditto
C. ditto
D. ditto
[check to select more options] Type 4
A. Contains fields for entering another data string and selecting from drop-down boxes
B. ditto
C. ditto
D. ditto
[check to show more options] Profile XYZ (as above)
[check to select more options] Profile STU (as above)
View 6 Replies
View Related
Sep 7, 2007
I'm working on a system that used to load control dynamically into a table structure based on "Row" and "Column" properties in the item object.
The system is now being revamped, and instead of a table structure, it's being loaded into a list, which will be controled by css. The new relevant variables are "Sequence" and "Width."
Since there are already thousands of existing items in the database, I have to write a script that can take a really good guess at legacy items' Row and Col, and input values for Sequence and Width.
Since all items exist on "tabs," I can query for all items on a given tabID, Ordered By Row, Col -- that will give me a sequence.
Width isn't literal, it has 6 presets: Whole, Half, Third, Quarter, Two Thirds, Three Quarters, represented in the table as 0,1,2,3,4,5 -- for our purposes, I'll assume that all items on a row are equal in width. We can determine width by figuring out the number of items within the same row, so if there is only one in the row, it's a Whole (0), if there are three in the row it'll be a Third (2), etc.
I'd like to create a query that gets all items by tab, assigns the appropriate sequence, and figures out how many items are in the row with a given item, to assign the correct width.... but I have no idea how to make t-sql do that. I don't mind multiple queries to get the whole process done, and it doesn't need to be efficient -- this is a one-off script to run to give legacy items values that we can work with.
Where would I start?
View 1 Replies
View Related
Oct 30, 2007
HI.
I have 3 tables
1- std with : stdID , programID.
2- Programs with :ProgramID , Cost
3 - Movements with : stdID , balance.
the first table contain the stdID and ProgramID , some times the std hasn't programID that mean he hasn't programID. then we return null.
if the std has programID there is to cases.
the first one he have a movement on his balance then we get the biggest balance for the std.
the second case he hasn't any moventen then we get his balance from Programs table by the ProgramID .
I need sql server function that return table like this
stdID , Balance
that means every std with his Balance.
Regards.
View 11 Replies
View Related
May 13, 2008
This is too complex anyone know how to make it less complex.
I am trying to get all the selected fields from contacts into a datagrid where the other fields contain a string in textbox1.
This works
SELECT [company], [contactname], [emailaddress], [secondemailaddress], [phonenumber], [webpage] FROM [contacts] WHERE (([AB] LIKE '%' + ? + '%') AND ([AL] LIKE '%' + ? + '%'))
When i add all the rest of the fields it says its too complex. Please Help
SELECT [company], [contactname], [emailaddress], [secondemailaddress], [phonenumber], [webpage] FROM [contacts] WHERE (([AB] LIKE '%' + ? + '%') AND ([AL] LIKE '%' + ? + '%') AND ([B] LIKE '%' + ? + '%') AND ([BB] LIKE '%' + ? + '%') AND ([BD] LIKE '%' + ? + '%') AND ([BA] LIKE '%' + ? + '%') AND ([BH] LIKE '%' + ? + '%') AND ([BL] LIKE '%' + ? + '%') AND ([BN] LIKE '%' + ? + '%') AND ([BR] LIKE '%' + ? + '%') AND ([BS] LIKE '%' + ? + '%') AND ([BT] LIKE '%' + ? + '%') AND ([CA] LIKE '%' + ? + '%') AND ([CB] LIKE '%' + ? + '%') AND ([CF] LIKE '%' + ? + '%') AND ([CH] LIKE '%' + ? + '%') AND ([CM] LIKE '%' + ? + '%') AND ( LIKE '%' + ? + '%') AND ([CR] LIKE '%' + ? + '%') AND ([CT] LIKE '%' + ? + '%') AND ([CV] LIKE '%' + ? + '%') AND ([CW] LIKE '%' + ? + '%') AND ([DA] LIKE '%' + ? + '%') AND ([DD] LIKE '%' + ? + '%') AND ([DE] LIKE '%' + ? + '%') AND ([DG] LIKE '%' + ? + '%') AND ([DH] LIKE '%' + ? + '%') AND ([DL] LIKE '%' + ? + '%') AND ([DN] LIKE '%' + ? + '%') AND ([DT] LIKE '%' + ? + '%') AND ([DY] LIKE '%' + ? + '%') AND ([E] LIKE '%' + ? + '%') AND ([EC] LIKE '%' + ? + '%') AND ([EH] LIKE '%' + ? + '%') AND ([EN] LIKE '%' + ? + '%') AND ([EX] LIKE '%' + ? + '%') AND ([FK] LIKE '%' + ? + '%') AND ([FY] LIKE '%' + ? + '%') AND ([G] LIKE '%' + ? + '%') AND ([GL] LIKE '%' + ? + '%') AND ([GU] LIKE '%' + ? + '%') AND ([GY] LIKE '%' + ? + '%') AND ([HA] LIKE '%' + ? + '%') AND ([HD] LIKE '%' + ? + '%') AND ([HG] LIKE '%' + ? + '%') AND ([HP] LIKE '%' + ? + '%') AND ( LIKE '%' + ? + '%') AND ([HU] LIKE '%' + ? + '%') AND ([HX] LIKE '%' + ? + '%') AND ([IM] LIKE '%' + ? + '%') AND ([IP] LIKE '%' + ? + '%') AND ([IV] LIKE '%' + ? + '%') AND ([JE] LIKE '%' + ? + '%') AND ([KA] LIKE '%' + ? + '%') AND ([KT] LIKE '%' + ? + '%') AND ([KW] LIKE '%' + ? + '%') AND ([KY] LIKE '%' + ? + '%') AND ([L] LIKE '%' + ? + '%') AND ([LA] LIKE '%' + ? + '%') AND ([LD] LIKE '%' + ? + '%') AND ([LE] LIKE '%' + ? + '%') AND ([LL] LIKE '%' + ? + '%') AND ([LN] LIKE '%' + ? + '%') AND ([LS] LIKE '%' + ? + '%') AND ([LU] LIKE '%' + ? + '%') AND ([M] LIKE '%' + ? + '%') AND ([ME] LIKE '%' + ? + '%') AND ([MK] LIKE '%' + ? + '%') AND ([ML] LIKE '%' + ? + '%') AND ([N] LIKE '%' + ? + '%') AND ([NE] LIKE '%' + ? + '%') AND ([NG] LIKE '%' + ? + '%') AND ([NN] LIKE '%' + ? + '%') AND ([NP] LIKE '%' + ? + '%') AND ([NR] LIKE '%' + ? + '%') AND ([NW] LIKE '%' + ? + '%') AND ([OL] LIKE '%' + ? + '%') AND ([OX] LIKE '%' + ? + '%') AND ([PA] LIKE '%' + ? + '%') AND ([PE] LIKE '%' + ? + '%') AND ([PH] LIKE '%' + ? + '%') AND ([PL] LIKE '%' + ? + '%') AND ([PO] LIKE '%' + ? + '%') AND ([PR] LIKE '%' + ? + '%') AND ([RG] LIKE '%' + ? + '%') AND ([RH] LIKE '%' + ? + '%') AND ([RM] LIKE '%' + ? + '%') AND ([S] LIKE '%' + ? + '%') AND ([SA] LIKE '%' + ? + '%') AND ([SE] LIKE '%' + ? + '%') AND ([SG] LIKE '%' + ? + '%') AND ([SK] LIKE '%' + ? + '%') AND ([SL] LIKE '%' + ? + '%') AND ([SM] LIKE '%' + ? + '%') AND ([SN] LIKE '%' + ? + '%') AND ([SO] LIKE '%' + ? + '%') AND ([SP] LIKE '%' + ? + '%') AND ([SR] LIKE '%' + ? + '%') AND ([SS] LIKE '%' + ? + '%') AND ([ST] LIKE '%' + ? + '%') AND ([SW] LIKE '%' + ? + '%') AND ([SY] LIKE '%' + ? + '%') AND ([TA] LIKE '%' + ? + '%') AND ([TF] LIKE '%' + ? + '%') AND ([TN] LIKE '%' + ? + '%') AND ([TQ] LIKE '%' + ? + '%') AND ([TR] LIKE '%' + ? + '%') AND ([TS] LIKE '%' + ? + '%') AND ([TW] LIKE '%' + ? + '%') AND ([UB] LIKE '%' + ? + '%') AND ([W] LIKE '%' + ? + '%') AND ([WA] LIKE '%' + ? + '%') AND ([WC] LIKE '%' + ? + '%') AND ([WD] LIKE '%' + ? + '%') AND ([WN] LIKE '%' + ? + '%') AND ([WR] LIKE '%' + ? + '%') AND ([WS] LIKE '%' + ? + '%') AND ([WV] LIKE '%' + ? + '%') AND ([YO] LIKE '%' + ? + '%'))
View 10 Replies
View Related
May 20, 2008
hi how are you please help me in my problem which i can't make it.
Now, i have a project in ASP.NET and SQL Server 2005. let's call the project an image gallery, in my project i have a table named "Category" in which all the categories are in this table. also while adding a new category a new table will be created automatically with the name of that category.
now, what i want is that to build a query that reads the contents of the tables that the tables name are the names of the each record in the "Category" table.
is that possible ?
please if any one help can me in my problem.
View 4 Replies
View Related
Feb 10, 2004
I have the following SQL 2000 database table:
NEWS (IDNews, Country, PublishDate, Title)
I have to get a dataset containing only one record for each country, having most recent publish date.
Any suggestions? Thanks.
View 3 Replies
View Related
Feb 8, 2005
I have 2 tables, say table1, and table2. There is a DocID (primary key) in table1. In table2, DocID is the foriegn key. There can be more than 1 DocID.
this is the table structure (sample)
Table 1:
DocID DocName OtherID etc
1 test 2
2 test2 3
Table2:
TblID DocID OtherID
1 1 10
2 1 13
3 1 25
how do I join these two tables, such that I get all the otherID's for each DocID.
ie.,
DocID OtherID
1 2 and 10 and 13 and 25
2 3
i am writing this query to display search results on a search page (with keyword search) and so, if I display the result in more than one row, then the user might think that there is more than document...whereas the case is that there is only one document with more than one other ID's.
is there any way I can do this? display...more than 1otherID in the same row for the same DociD?
Currently, I am using a left outer join of table1 and table2.
An suggestions on how to do this?
View 6 Replies
View Related
Oct 1, 2005
I cant get "order by" to work in this sql query..I use this query:
"SELECT DISTINCT TOP 12 name,total = COUNT(*) FROM products where kat = 'music' group by namn"and I want to add this some where to get 12 random records: "ORDER BY NewID()"I tried this: "SELECT DISTINCT TOP 12 name,total = COUNT(*) FROM products where kat = 'music' group by namn ORDER BY NewID()"" but get the error:"ORDER BY items must appear in the select list if SELECT DISTINCT is specified"I can´t figure out how I should write the query..Somebody have any ideas??/Radiwoi
View 2 Replies
View Related
Apr 11, 2003
Hi,
I need a way to retrieve records from a table with a 30 min interval between the records.
For e.g., Lets say I have the following data in a table :-
userid hitdt
1 4/1/2003 10:00 AM
1 4/1/2003 10:15 AM
1 4/1/2003 10:31 AM
1 4/1/2003 11:10 AM
1 4/1/2003 11:30 AM
1 4/1/2003 11:41 AM
I need a query which would return me the following recordset :-
userId hitId
1 4/1/2003 10:00 AM
1 4/1/2003 10:31 AM
1 4/1/2003 11:10 AM
1 4/1/2003 11:41 AM
Is there a way to do this without using a cursor ?
Thanks
View 7 Replies
View Related
Sep 7, 2003
table_a has patient_id, tran_id and other fields a,b,c
table_b has patient_id,tran_id, key_id
and other fileds d,e,f
table_a patien_id + tran_id is unique
table_b patient_id + tran_id is not unique, could be duplicated.
I have to create a query which will retrieve fields from table a a,b,c and fields d,e from table b where
table a. patient_id + tran_id =
tableb.patient_id + tran_id and table_b.key_id is the min key_id for that patient_id + tran_id.
I should retrieve just one record.
How would I be able to do that?
Please help!!
Thanks
View 2 Replies
View Related