Select Distinct records
Hi..
I'm getting error when trying to fill the combo using select with distinct command....i have duplicate records but recordset is not working with distinct command....
Thanks..
Hi Pari,
you can solve this using GROUP By
Select U_ELCategoryCode,U_ELCategoryName from [@ENTITLEMENTCATEGORY]
group by U_ELCategoryCode,U_ELCategoryName
that will remove records where U_ELCategoryCode and U_ELCategoryName are the same.
lg David
Similar Messages
-
"Select Distinct Records" Option Not Available
Hello Experts.
I am working on a new report in CR XI, and noticed that I had many duplicate records. I went to the File; Report Options; and expected to click on "Select Distinct Records", but that choice was grayed-out. What would have caused me to lose this option, and how do I fix it?
Thanks in advance for your help.Not sure if this covers it or not, but....
The Select Distinct Records command is only available for ODBC, OLE DB, and SQL native drivers; it is not available for Stored Procedures. Note also that your server may automatically sort returned values if no sort is specified in Crystal Reports. -
Select distinct records in Mapping with no Key field (all fields can vary)
Hi Experts,
Let me take an example (not the actual requirement but same scenario) to explain the problem where I need your help to get best possible way to resolve. This has to be achieved in mapping, don't have other options as its part of complex end 2 end scenario.
I have following input XML:
<Employee>
<Details>
<Id>123</Id>
<Name>ABC</Name>
<Role>Manager</Role>
<Area>Bangalore</Area>
</Details>
<Details>
<Id>123</Id>
<Name>ABC</Name>
<Role>Manager</Role>
<Area>Pune</Area>
</Details>
<Details>
<Id>123</Id>
<Name>ABC</Name>
<Role>Advisor</Role>
<Area>Bangalore</Area>
</Details>
<Details>
<Id>123</Id>
<Name>ABC</Name>
<Role>Manager</Role>
<Area>Bangalore</Area>
<Details>
<Id>143</Id>
<Name>ABC</Name>
<Role>Manager</Role>
<Area>Bangalore</Area>
</Details>
</Employee>
The output XML is:
<Employee>
<MainRec>
<Id>123</Id>
<Name>ABC</Name>
<table name = 'Roles'>
<record>
<Id>123</Id>
<Role>Manager</Role>
<Area>Bangalore</Area>
</record>
<record>
<Id>123</Id>
<Role>Manager</Role>
<Area>Pune</Area>
</record>
<record>
<Id>123</Id>
<Role>Advisor</Role>
<Area>Bangalore</Area>
</record>
</table>
</MainRec>
<MainRec>
<Id>123</Id>
<Name>ABC</Name>
<table name = 'Roles'>
<record>
<Id>143</Id>
<Role>Manager</Role>
<Area>Bangalore</Area>
</record>
</table>
</MainRec>
</Employee>
As you can see from the example above, here I want to populate only distinct records under table, but there is no key fiield to ditunguish. Any of the 3 fields (Id, Role,Area) can vary and between 2 records if all of these fields are same then its duplicate else select it. So in above XML just discard the 4th record from the source XML and populate all others. Each record has to be checked against all other records all 3 values (ID, Role, Area). Only when none of the records have exactly the same values, populate it.
Also records with different ID come under different table node. Hope my requirement is clear, if not please let me know, i will try to explain better.
I thought of creating a UDF to achieve this but not able to decide how to match it to the output message here.
Best Regards,
PratikHi,
For the main record, I think you only need to check for each unique ID, e.g
Id --> removeContext --> sort:ascending --> splitByValue:valueChanged --> collapseContext --> MainRec
For the record, however, you need to create a UDF that will filter out the duplicate values. For this, the UDF sample mentioned here contained multipleResult lists
Id --> removeContext --> concat: : --> concat: : --> UDF --> splitByValue:ValueChanged --> record
role --> removeContext --> / / \ --> Id
area --> removContext -------------> / \ --> role
\ --> area
Context type UDF
Arguments: input
Result: IdResult
Result: roleResult
Result: areaResult
Vector temp = new Vector();
for(int a=0;a<input.length;a++){
if(!temp.contains(input[a])
temp.add(input[a]);
for(int a=0;a<temp.size();a++){
String tmp = (String) temp.get(a);
/*split according to field */
IdResult.addValue(tmp.substring(0,tmp.indexOf(":")));
roleResult.addValue(tmp.substring(tmp.indexOf(":")+1,tmp.lastIndexOf(":")));
areaResult.addValue(tmp.substring(tmp.lastIndexOf(":")+1,tmp.length()));
note: Id and record will both be using the IdResult list.
Hope this helps,
Mark -
Select distinct records without using distinct
hi experts,
my retrieved data like these:
cnt_id cnt_type rcrd_id wrkflw_id
558848 PRODUCT 553503 248
558848 PRODUCT 553503 248
558848 PRODUCT 553503 248
558808 PRODUCT 553463 248
558808 PRODUCT 553463 248
558808 PRODUCT 553463 248
558810 PRODUCT 553463 248
558810 PRODUCT 553463 248
558810 PRODUCT 553463 248
now i want to select one record for each cnt_id without using any distinct function .. how can i do that?
regards,
SKPyou can use the below query
select * from t where rowid in (select max(rowid)
from t group by cnt_id)You're query is not the equivalent of DISTINCT.
SQL> ed
Wrote file afiedt.buf
1 create table t as
2 (select 558848 as cnt_id, 'PRODUCT' as cnt_type, 553503 as rcrd_id, 248 as wrkflw_id from dual union all
3 select 558848, 'RETURN', 553503, 248 from dual union all
4 select 558848, 'PRODUCT', 553503, 248 from dual union all
5 select 558808, 'PRODUCT', 553463, 248 from dual union all
6 select 558808, 'PRODUCT', 553463, 248 from dual union all
7 select 558808, 'PRODUCT', 553463, 248 from dual union all
8 select 558810, 'PRODUCT', 553463, 248 from dual union all
9 select 558810, 'PRODUCT', 553463, 248 from dual union all
10* select 558810, 'PRODUCT', 553463, 248 from dual)
11 /
Table created.
Elapsed: 00:00:00.01
SQL> select * from t where rowid in (select max(rowid) from t group by cnt_id);
CNT_ID CNT_TYP RCRD_ID WRKFLW_ID
558810 PRODUCT 553463 248
558808 PRODUCT 553463 248
558848 PRODUCT 553503 248
Elapsed: 00:00:00.00
SQL> select distinct * from t;
CNT_ID CNT_TYP RCRD_ID WRKFLW_ID
558810 PRODUCT 553463 248
558808 PRODUCT 553463 248
558848 RETURN 553503 248
558848 PRODUCT 553503 248
Elapsed: 00:00:00.00
SQL> -
Select distinct records in query
If I want to read a table in an infoset, how can I just select distinct entries from the table?
Is it done at the infoset level or the query level?I've actually created the infoset for table VBFA and created a query.
But I can't limit the output such that for each DO, show only distinct subsequent Invoice.
eg. DO 123 has 3 items, and this DO 123 has only 1 Invoice 456, then in the output, there will be
DO | Invoice
123 | 456
123 | 456
123 | 456
It's repeated 3 times because there are 3 items in VBFA for this DO. How can I create the infoset/query so that the output will be 1 entry only, ie
DO | Invoice
123 | 456
Thanks -
Select distinct record based on column
Hello All,
I have a table that has more than one row as Detail for a single invoice number(screenshot below). When I create report based on this table, I get multiple rows for single invoice. I mean Invoice 000027 shows up with 5 different rows on the SSRS report.
Is there a way I could display a single row for a single invoice? Any thoughts on this will be greatly appreciated. Thanks.
Regards,
Amol
eport )Thank you all for your suggestions. The issue is how can I get single distinct columns after joining 2 tables (InvoiceHeader & InvoiceDetail). I am using following query in my dataset.
SELECT DISTINCT I.recid, I.InvNumber, D.Detail, I.CompanyName, I.Addr1, I.SalesRep, I.JobNumber, I.Status, I.InvDate, I.TotalInvAmount
FROM InvoiceHeader AS I INNER JOIN
InvoiceDetails AS D ON I.InvNumber = D.InvoiceNumber
WHERE (I.InvNumber = @InvoiceNumber) AND (I.InvDate >= @StartDate) AND (I.InvDate <= @EndDate) AND (I.CompanyName IN (@Customer)) AND (I.Status IN (@Status)) OR
(I.InvDate >= @StartDate) AND (I.InvDate <= @EndDate) AND (I.CompanyName IN (@Customer)) AND (I.Status IN (@Status)) AND (I.JobNumber = @JobNo) OR
(I.InvNumber = @InvoiceNumber) AND (I.InvDate >= @StartDate) AND (I.InvDate <= @EndDate) AND (I.CompanyName IN (@Customer)) AND (I.Status IN (@Status))
AND (@JobNo = '') OR
(I.InvDate >= @StartDate) AND (I.InvDate <= @EndDate) AND (I.CompanyName IN (@Customer)) AND (I.Status IN (@Status)) AND (I.JobNumber = @JobNo) AND
(@JobNo = '') OR
(I.InvDate >= @StartDate) AND (I.InvDate <= @EndDate) AND (I.CompanyName IN (@Customer)) AND (I.Status IN (@Status)) AND (@JobNo = '') AND
(@InvoiceNumber = '')
ORDER BY I.InvNumber DESC
Thanks again.
Amol -
Distinct Records Selection in Crystal 11
Need to select Distinct Records only, but the drop down under 'Database' shows the 'Select Distinct Records' option grayed out. Why does Crystal do that, and how may I eliminate duplicate records? Thanks!
Hi Brian,
This issue normally comes when there are multiple datasources being used. For example if you are using two databases, like Oracle and MS Access to fetch data, the "Select Dictinct Records" will be greyed out.
In this case, you might want to write a query in the Add Command option which select distinct records.
If you are using only one database, then check if you are able to select "Select Dinstinct Records" in the Database menu.
Please let us know if this helps.
Regards,
Abhishek. -
Selecting distinct combination of records
Hi Expart ,
I have table fields like function ,tcode,objects,fields,from ,to ,user like that in which except user all r primary key fields but i want Number of unique Function-Tcode-Object combinations when select the data.
i am doing like that
SELECT COUNT( distinct FUNCTIONID TCODE OBJECT)
FROM /PSYNG/FUNCTTRAN
INTO L_FUN_TCD_OB
WHERE VRSIO = P_VRSIN.
but it will give an error
plz help me to get no of this combination of records .
Thanks in advance .
Tsenhi
u can write code like this
SELECT distinct FUNCTIONID TCODE OBJECT
FROM /PSYNG/FUNCTTRAN
INTO table it_L_FUN_TCD_OB
WHERE VRSIO = P_VRSIN.
data: var type sy-tabix.
describe table it_L_FUN_TCD_OB lines var.
L_FUN_TCD_OB = var.
refresh it_L_FUN_TCD_OB.
Regards
Sajid -
Distinct records with conditional select formula
Post Author: nelsonchris
CA Forum: Data Connectivity and SQL
Hello,
I have a simple report pulling data from two tables. I want
only distinct records. I am selecting records based on
parameters; here is the select formula:
({?Service Name} = "*" or {selsvc.ServiceName} like
{?Service Name})and
({?Program Name} = "*" or {selsvc.Selected Service Entry
Program Name} like {?Program Name}) and
({?Agency Name} = "*" or {selsvc.Selected Service Entry
Agency Name} like {?Agency Name})
The problem comes from the fact that Crystal will add the
selsvc fields to the reports SQL select code, which has the
effect of duplicating some records that do not have the same
values for the selsvc fields. The select formula above is
the only place in the report where values from the selsvc
field are used, and as you can see they are only used when
the user has submitted a matching parameter for them. I can
not figure out how to get rid of the duplicates, please
help!
Thanks for your time,
ChrisPost Author: yangster
CA Forum: Data Connectivity and SQL
I don't follow why you are getting duplicates with your selectionare you getting duplicates without the selection criteria?if you are then they really are not duplicates and there could be issues with your joins between the 2 tables -
Select single record per distinct type
My test table is shown below, I needed to return just ONE invoice for each distinct prov_type
PROV_TYPE INVOICE
E 111
E 222
E 333
AL 444
I could use: SELECT distinct prov_type,
min(invoice)
FROM test_table
Yields (one invoice per prov_type):
Prov_type Invoice
E 111
AL 444
But to extend this, how would I get the same result when
there are more than just the 2 columns (prov_type and invoice)?
Example data (selected from numerous tables):
PROV_TYPE INVOICE SOME_DATES SCHEDULE
E 111 JUNE 1 40A
E 222 JUNE1 7A-C
E 333 MAY 1 20C
AL 444 JULY 1 7C-R
I'm trying to select ONE invoice example of
each prov_type.
Is there any way to write something to
get one record of each type of prov_type?....without having to execute the
underlying where clause twice (once to get the distinct prov type and min
invoice, and one to get the rest of the data for the invoice???)? I'm wondering this
because the underlying where clause to get the above data set could be slow.
I keep thinking there should be some way to select the above data set, and
then somehow use a subquery or rownum or count(*) or something else to pick and choose the
records I want from this set.
Also, I have something similar to this where I select a bunch of data, and I
want one record where a type column = R and one record where the same type
column is NOT R. Same idea.. is there any way to select the "bunch of
data" one time and manipulate the result set? Or do I have to:
SELECT a_bunch_of_data
FROM a_bunch_of_tables
WHERE a_bunch_of_conditions
AND the_type = 'R'
AND rownum < 2
UNION
SELECT a_bunch_of_data (AGAIN)
FROM a_bunch_of_tables (AGAIN)
WHERE a_bunch_of_conditions (AGAIN)
AND the_type <> 'R'
AND rownum < 2Using PL/SQL AND/OR Dynamic SQL can simplify this. If your requirement
is strictly SQL however, and your main goal is not to have to join
anything else to your view, one (tricky) way would involve the following:
1. get the data length of each needed column (except the key column) from the table definition.
2. convert each of these column into character type, left padded to its data length
3. concatenate these columns, with the target column in the front (e.g. Invoice Number)
4. Apply the group function on the concatenated string, grouping by the key column.
5. parse the string back
This shouldn't be bad if you have to set it up only once!
Note: for the second problem, you can use the same technique, with:
GROUP BY DECODE(the_type,'R','R','Not R')
CREATE TABLE test_table (
PROV_TYPE VARCHAR2(10),
INVOICE NUMBER,
SOME_DATE DATE,
SCHEDULE VARCHAR2(20),
some_num_field NUMBER(5,3)
INSERT INTO test_table VALUES('E',111,TO_DATE('JUN 1','MON DD'),'40A',12.123);
INSERT INTO test_table VALUES('E',22,TO_DATE('JUN 1','MON DD'),'7A-C',3.04);
INSERT INTO test_table VALUES('E',333,TO_DATE('MAY 1','MON DD'),'20C',1.4);
INSERT INTO test_table VALUES('AL',444,TO_DATE('JUL 1','MON DD'),'7C-R',9);
INSERT INTO test_table VALUES('Z',9,TO_DATE('JUL 1','MON DD'),'7C-R',12.123);
INSERT INTO test_table VALUES('Z',123,TO_DATE('JUL 1','MON DD'),'7C-R',12.123);
INSERT INTO test_table VALUES('Z',999,TO_DATE('JUL 1','MON DD'),'7C-R',99.999);
SELECT
PROV_TYPE,
TO_NUMBER(SUBSTR(
MIN(LPAD(invoice,38) | | TO_CHAR(some_date,'YYYYMMDDHH24MISS') | |
LPAD(schedule,20) | | LPAD(some_num_field,39)),
1,38)) invoice,
TO_DATE(SUBSTR(
MIN(LPAD(invoice,38) | | TO_CHAR(some_date,'YYYYMMDDHH24MISS') | |
LPAD(schedule,20) | | LPAD(some_num_field,39)),
38+1,14),'YYYYMMDDHH24MISS') some_date,
LTRIM(SUBSTR(
MIN(LPAD(invoice,38) | | TO_CHAR(some_date,'YYYYMMDDHH24MISS') | |
LPAD(schedule,20) | | LPAD(some_num_field,39)),
38+14+1,20)) schedule,
TO_NUMBER(SUBSTR(
MIN(LPAD(invoice,38) | | TO_CHAR(some_date,'YYYYMMDDHH24MISS') | |
LPAD(schedule,20) | | LPAD(some_num_field,39)),
38+14+20+1,39)) some_num_field
FROM test_table
GROUP BY prov_type
/null -
Serious performance problem - SELECT DISTINCT x.JDOCLASSX FROM x
I am noticing a huge performance problem when trying to access a member that
is lazily loaded:
MonitorStatus previousStatus = m.getStatus();
This causes the following query to be executed:
SELECT DISTINCT MONITORSTATUSX.JDOCLASSX FROM MONITORSTATUSX
This table has 3 million records and this SQL statement takes 3 minutes to
execute! Even worse, my app heavily uses threads, so this statement is
executed in each of the 32 threads. As a result the application stops.
Is there any way that I can optimize this? And more importantly, can Kodo
handle a multithreaded app like this with a huge database? I've been having
a lot of performance problems since I've started doing stress & load
testing, and I'm thinking Kodo isn't ready for this type of application.
Thanks,
MichaelYou can prevent this from happening by explicitly enumerating the valid
persistent types in a property. See
http://docs.solarmetric.com/manual.html#com.solarmetric.kodo.PersistentTypes
for details.
>
Inconveniently, this nugget of performance info is not listed in the
optimization guide. I'll add in an entry for it.This setting did in fact prevent the query from running which fixed the
problem. It definitely belongs in the optimization guide.
And more importantly, can Kodo
handle a multithreaded app like this with a huge database? I've beenhaving
a lot of performance problems since I've started doing stress & load
testing, and I'm thinking Kodo isn't ready for this type of application.I'd like to find out more information about details about your issues. We
do a decent amount of stress / load testing internally, but there are
always use cases that we don't test. Please send me an email (I'm assuming
that [email protected] is not really your address) and let's
figure out some way to do an analysis of what you're seeing.This email is just for posting to usenet, to avoid spam. I'm now running my
app through stress/load testing so I hope to discover any remaining issues
before going into production. As of this morning the system seems to be
performing quite well. Now the biggest performance problem for me is the
lack of what I think is called "outer join". I know you'll have this in 3.0
but I'm suprised you don't have this already because not having it really
affects performance. I already had to code one query by hand with JDBC due
to this. It was taking 15+ minutes with Kodo and with my JDBC version it
only takes a few seconds. There are lots of anti-JDO people and performance
issues like this really give them ammunition. Overall I just have the
impression that Kodo hasn't been used on many really large scale projects
with databases that have millions of records.
Thanks for configuration fix,
Michael -
Selecting unique records- Removing consecutive same data
HI,
am having a table where in some x,y,msg_date_info fields are there...here the data is in huge number...i need to fetch the data from this table subject to the following query conditions.
SELECT X longit,Y latit,MSG_DATE_INFO,row_number() over (order by MSG_DATE_INFO asc) SlNo FROM
(SELECT distinct x,y,MSG_DATE_INFO,row_number() over (order by MSG_DATE_INFO desc) r
FROM TRACKING_REPORT WHERE MSISDN='123456789') WHERE R between 1 and 20this works fine...
here one more thing i want to add up...this query results in 20 rows as expected and i want to filter the records if consecutive x and y values of these rows are same and give only unique values of x and y(condition that same x and y can be there somewhere in the order of data).
this example will show what is my requirement in detail....and this is the output of the above query
>
80.20550609 13.09469998 08-Mar-10 19:23:23 1
80.20550609 13.09469998 08-Mar-10 19:28:37 2
80.20087123 13.09437811 08-Mar-10 19:33:25 3
80.20550609 13.09469998 08-Mar-10 19:38:24 4
80.20550609 13.09469998 08-Mar-10 19:43:25 5
80.20550609 13.09469998 08-Mar-10 19:48:25 6
80.20087123 13.09437811 08-Mar-10 19:53:25 7
80.20087123 13.09437811 08-Mar-10 19:58:24 8
80.20550609 13.09469998 08-Mar-10 20:03:25 9
80.20087123 13.09437811 08-Mar-10 20:08:24 10
80.20550609 13.09469998 08-Mar-10 20:13:24 11
80.20087123 13.09437811 08-Mar-10 20:18:37 12
80.20550609 13.09469998 08-Mar-10 20:23:32 13
80.20550609 13.09469998 08-Mar-10 20:28:25 14
80.20550609 13.09469998 08-Mar-10 20:33:23 15
80.20550609 13.09469998 08-Mar-10 20:38:24 16
80.20550609 13.09469998 08-Mar-10 20:43:24 17
80.20550609 13.09469998 08-Mar-10 20:48:24 18
80.20550609 13.09469998 08-Mar-10 20:53:22 19
80.20550609 13.09469998 08-Mar-10 20:58:24 20
>
from this output i need to filter out CONSECUTIVE unique x and y values. and the output has to be like
>
80.20550609 13.09469998 08-03-10 19:23 1
80.20087123 13.09437811 08-03-10 19:33 3
80.20550609 13.09469998 08-03-10 19:48 6
80.20087123 13.09437811 08-03-10 19:53 7
80.20550609 13.09469998 08-03-10 20:03 9
80.20087123 13.09437811 08-03-10 20:08 10
80.20550609 13.09469998 08-03-10 20:13 11
80.20087123 13.09437811 08-03-10 20:18 12
80.20550609 13.09469998 08-03-10 20:58 20
>
how to go about this requirement?
Edited by: Aemunathan on Mar 9, 2010 5:45 PMThe following gives the same results on your test data but maybe it's more accurate because searches both for changes in x and in y:
SQL> with mytab as (
2 select 80.20550609 x, 13.09469998 y, '08-Mar-10 19:23:23' mydate, 1 rn from dual union
3 select 80.20550609,13.09469998, '08-Mar-10 19:28:37', 2 from dual union
4 select 80.20087123,13.09437811, '08-Mar-10 19:33:25', 3 from dual union
5 select 80.20550609,13.09469998, '08-Mar-10 19:38:24', 4 from dual union
6 select 80.20550609,13.09469998, '08-Mar-10 19:43:25', 5 from dual union
7 select 80.20550609, 13.09469998, '08-Mar-10 19:48:25', 6 from dual union
8 select 80.20087123, 13.09437811, '08-Mar-10 19:53:25', 7 from dual union
9 select 80.20087123, 13.09437811, '08-Mar-10 19:58:24', 8 from dual union
10 select 80.20550609, 13.09469998, '08-Mar-10 20:03:25', 9 from dual union
11 select 80.20087123, 13.09437811, '08-Mar-10 20:08:24', 10 from dual union
12 select 80.20550609,13.09469998, '08-Mar-10 20:13:24', 11 from dual union
13 select 80.20087123, 13.09437811, '08-Mar-10 20:18:37', 12 from dual union
14 select 80.20550609, 13.09469998, '08-Mar-10 20:23:32', 13 from dual union
15 select 80.20550609, 13.09469998, '08-Mar-10 20:28:25', 14 from dual union
16 select 80.20550609, 13.09469998, '08-Mar-10 20:33:23', 15 from dual union
17 select 80.20550609, 13.09469998, '08-Mar-10 20:38:24', 16 from dual union
18 select 80.20550609, 13.09469998, '08-Mar-10 20:43:24', 17 from dual union
19 select 80.20550609, 13.09469998, '08-Mar-10 20:48:24', 18 from dual union
20 select 80.20550609, 13.09469998, '08-Mar-10 20:53:22', 19 from dual union
21 select 80.20550609, 13.09469998, '08-Mar-10 20:58:24', 20 from dual
22 )
23 select x, y, mydate, rn from (
24 select x, y, mydate, rn, nvl(lead(x) over (order by rn),0) next_x
25 , nvl(lead(y) over (order by rn),0) next_y
26 from mytab
27 ) where next_x != x or next_y != y;
X Y MYDATE RN
80.20550609 13.09469998 08-Mar-10 19:28:37 2
80.20087123 13.09437811 08-Mar-10 19:33:25 3
80.20550609 13.09469998 08-Mar-10 19:48:25 6
80.20087123 13.09437811 08-Mar-10 19:58:24 8
80.20550609 13.09469998 08-Mar-10 20:03:25 9
80.20087123 13.09437811 08-Mar-10 20:08:24 10
80.20550609 13.09469998 08-Mar-10 20:13:24 11
80.20087123 13.09437811 08-Mar-10 20:18:37 12
80.20550609 13.09469998 08-Mar-10 20:58:24 20
9 rows selected.Max
http://oracleitalia.wordpress.com -
Help! Howto use the join function in a query with select distinct ?
Hi!
I have 2 tables. I want to select only 1 painting of each artists.
select distinct idartist
from tbl_artworks
where blah blah blah
order by rand()
how does the "join" function work for add: name, lastname, title, image and much more... i try... but i fail...
tbl_artists
idartist
name
lastname
1
Paul
Gaugain
2
Vincent
Van Gogh
3
Pablo
Picasso
tbl_artworks
idartwork
idartist
title
image
1
1
days of gods
image1.jpg
2
2
sunflower
image2.jpg
3
3
Dora maar au chat
image3.jpg
4
2
Sky
image4.jpg
5
3
La vie
image5.jpgGetting a single random image for each probably requires a combination of sql and cf. It would take someone smarter than me to do it with sql alone. I would probably try something like this:
1. Run a database query that gets all the images from all the artists.
2. Run a Q of Q that gets a distinct list of artist ids.
3. Loop through that list and run a Q of Q to get all the images for that artist.
4. Still in that loop, use randrange (1 to the recordcount) to select a random record from your Q of Q -
Select distinct from an infoset query
Hello
I need to select distinct / delete duplicate from an infoset query created thru SQ02.
Please let me to know how this can be done?
Many thanks in advance!
regards
SanjyotHi,
You can verywell use infoset query if you are doing following things
Join using Keyfields to retreive data from tables
If not using keyfields create index for those table fields in those fields which will improve in accessing database
Try to use minimum of tables of small size dont try to join big tables like GLPCA and all.
Try to load small set of data like a period or month. Dont try for a year or so.
if your performance is good for aperiod you can go for a year.
If you are good in function module you can try function module in which you will have the option of specifying no of records to be selected usign package size.
Hope this helps for you.
Thanks,
Arun -
SELECT DISTINCT does not work. Why?
Dear All,
I wrote the Query below in SAP B1 8.8 and it works fine.
But, for some strange reason, certain records are duplicated.
Could anybody explain why?
I tried to eliminate the duplicates by changing the 1st line of the Query from SELECT to SELECT DISTINCT
Error Message:
The ntext data type cannot be selected as DISTINCT because it is not comparable.
Could you help amend the Query?
Thanks
Leon Lai
SELECT
T0.[UpdateDate] AS 'Update Dt',
T0.[TaxDate] AS 'Doc Dt',
CASE T5.[TransType]
WHEN '18' THEN 'PU ' + CONVERT(VARCHAR(6), T0.[DocNum])
WHEN '19' THEN 'PC ' + CONVERT(VARCHAR(6), T0.[DocNum])
END 'SAP Ref.',
T1.[ImportLog] AS 'Ship #',
T0.[CardCode] + '' AS 'Supplier #',
T0.[CardName] AS 'Supplier Name',
T0.[DocTotal] AS 'Rs',
T1.[BlockNum] AS 'Reqn #',
T0.[DocNum] AS 'Doc No',
T0.[U_SupInv] AS 'Link'
FROM klship.[dbo].[OPCH] T0
INNER JOIN klship.[dbo].[PCH1] T1 ON T0.[DocEntry] = T1.[DocEntry]
INNER JOIN klship.[dbo].[OJDT] T5 ON T0.[TransID] = T5.[TransID]
WHERE
(T0.[UpdateDate] >= '[%2]' AND
T0.[UpdateDate] <= '[%3]' AND
T0.[U_SupInv] IS NULL)
OR
(T0.[UpdateDate] >= '[%4]' AND
T0.[UpdateDate] <= '[%5]' AND
T0.[U_SupInv] IS NOT NULL)
FOR BROWSE
Note: - U_SupInv is a UDF used to attach a scanned pdf file to the Supplier's Invoice.Dear István Korös,
Thanks a lot for your answer.
Your suggestion works!
I am closing this thread.
However, I have never met the problem of duplicate records before
with such straightforward Queries.
If you could explain to me why such duplicates arose, it would be very
satisfying.
Best Regards
Leon Lai
Maybe you are looking for
-
File Sharing - Shared folder with forward slash in name
I have a shared folder that has a forward slash in the name: Test/Folder I can't remove it. Any suggestions on how to delete this from the File Sharing?
-
The Download button on the Download page just reloads the same Download page... How can I fix this?!
-
OS X 10.4.6 Messes up my computer
I've been having lots of problems with my computer recently. I've been fiddling around with it for the past few hours, and I'm pretty sure I know what the problem is. OS X 10.4.6 I've reformatted twice, and after every time I've installed OS X 10.4.6
-
Fireworks not listed in Open With in Vista
can't get jpgs to Associate with Fireworks CS3 in Vista - if i select "Choose Default Program" and browse to Fireworks.exe it still won't show up in the dialog. also doesn't appear in Open With in the Context menu... in the Default Programs option in
-
Layer 2 Interworking ETH/Vlan to FR
hi everyone, i'm issuing a problem with the Layer 2 ETH/VLAN to Frame relay interwroking. actually it works fine on the ETH/VLAN Side , the problem occure on the FR side where i notification msg while executing a CLI commande : PEconfig)#connect fr_i