Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Strucked!!!

Author  Topic 

sohail.mahmood69
Starting Member

7 Posts

Posted - 2011-02-03 : 00:51:46
SELECT per_request_aud.user_id, per_request_aud.date_stamp,
DECODE (per_request_aud.request_no, 1, 'Old', 2, 'New'),
per_request_aud.request_no,
pda.request_type (per_request_aud.request_type) req_type,
per_request_aud.person_name1
|| ' '
|| per_request_aud.person_name2
|| ' '
|| per_request_aud.person_name3
|| ' '
|| per_request_aud.person_name4
|| ' '
|| per_request_aud.person_name5,
per_request_aud.per_id, per_request_aud.card_no,
per_request_aud.mobile_no1, per_request_aud.approved_amount
FROM per_request_aud
WHERE TO_CHAR (per_request_aud.date_stamp) LIKE :date_input
ORDER BY per_request_aud.trans_seq
GROUP BY per_request_aud.per_id



I am using above query to get rows together having same column value...But I dont know why i m getting an error of invalid sql command... Please Help

Sohail Malik

MIK_2008
Master Smack Fu Yak Hacker

1054 Posts

Posted - 2011-02-03 : 01:20:21
Seems that you are working on Oracle ... if so please post your question on Oracle Forums as this is Microsoft SQL server one....!

Cheers
MIK
Go to Top of Page

sohail.mahmood69
Starting Member

7 Posts

Posted - 2011-02-03 : 01:22:36
Okay... Thanks, but btw if you know the problem can you help me in this regrads??

And is this query correct??
Go to Top of Page

MIK_2008
Master Smack Fu Yak Hacker

1054 Posts

Posted - 2011-02-03 : 01:37:27
well Sohail have not worked on Oracle for some time so dont have confirmed knowledge over the syntax. however try to debug the code in parts as i usually do when i get generic sort of errors. try running the code in parts .. e.g.

1)
Select Col1
From TableName

2) Select Col1,Col2
From TableName

3)Select Col1,Col2,...,ColN
From TableName

4)Select Col1,Col2,...,ColN
From TableName
Where <conditions>
.
.
.

This way you will at least find out the problematic portion of a code :D

Cheers
MIK
Go to Top of Page

sohail.mahmood69
Starting Member

7 Posts

Posted - 2011-02-03 : 02:13:06
sure, i have done this before. And many many thanks for the reply. Let me easy ur life, when i placed the line below in the query it give me error.

GROUP BY per_request_aud.per_id


the query is running fine without group by clause, I want to show two rows together having same Per_id.

I hope that you understand my problem and I also wish to get a reply from you soon =)
Go to Top of Page

MIK_2008
Master Smack Fu Yak Hacker

1054 Posts

Posted - 2011-02-03 : 02:19:12
quote:
Originally posted by sohail.mahmood69

sure, i have done this before.



Don't think so .. otherwise you should have figured it out .. !! anyhow good to know that you have fixed it out !!


Cheers!
MIk
Go to Top of Page

sohail.mahmood69
Starting Member

7 Posts

Posted - 2011-02-03 : 02:23:50
I think u mis-understood me.... the query is running fine without the "Group By" clause. When I put this clause then I am having an error =(

Sohail Malik
Go to Top of Page

MIK_2008
Master Smack Fu Yak Hacker

1054 Posts

Posted - 2011-02-03 : 02:30:36
"the query is running fine without group by clause, I want to show two rows together having same Per_id"


Well you might know that Group By Works over Group Functions e.g. Avg, Sum, Count etc ... Group By clause is not for the --> "two rows tegether having same per_ID". Perhaps you can use DISTINCT sort of clause in Oracle for what you what .. however that will works only if there is Duplication at Row Level (values in columns are same)


Cheers!
MIK
Go to Top of Page

sohail.mahmood69
Starting Member

7 Posts

Posted - 2011-02-03 : 02:42:32
Thank You =)

One more question!
DISTINCT is for getting different data. Any clause for getting same data together??
Go to Top of Page

MIK_2008
Master Smack Fu Yak Hacker

1054 Posts

Posted - 2011-02-03 : 02:50:08
:-$ i think i am getting confused :D or i am unable to understand what you want ..

Do you want the duplication to be there in your data set but to show the duplicated rows at adjacent to each other ("Any clause for getting same data together")?

if this is so Then use -- Order By Per_id
Go to Top of Page

sohail.mahmood69
Starting Member

7 Posts

Posted - 2011-02-03 : 02:55:26
this discussion is getting more and more complex or it will become complex if i started explaining you the whole query. let the things easy and think that there will be idealism around =)

anyways thanks for sparing your time here in my problem =)

Sohail Malik
Go to Top of Page
   

- Advertisement -