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.
Author |
Topic |
Kelapa
Starting Member
8 Posts |
Posted - 2013-04-12 : 03:43:23
|
What am I doing wrong? |
|
bandi
Master Smack Fu Yak Hacker
2242 Posts |
Posted - 2013-04-12 : 03:48:38
|
I think subquery(GPAD) is returning more than one row...Subquery must return only one value per rowNOTE:You can't use column alias in the GROUP BY clause ( in SQL Server) |
|
|
Kelapa
Starting Member
8 Posts |
Posted - 2013-04-12 : 04:11:40
|
quote: Originally posted by bandi I think subquery(GPAD) is returning more than one row...Subquery must return only one value per rowNOTE:You can't use column alias in the GROUP BY clause ( in SQL Server)
But I can get results separately from my two queries if I run them one by one. |
|
|
Kelapa
Starting Member
8 Posts |
Posted - 2013-04-12 : 04:26:22
|
quote: Originally posted by bandi I think subquery(GPAD) is returning more than one row...Subquery must return only one value per row
Btw, You totally right about that! |
|
|
bandi
Master Smack Fu Yak Hacker
2242 Posts |
Posted - 2013-04-12 : 04:36:50
|
Yes you can get by separate queries....--May be try this...SELECT e.Gk_2, (SELECT MAX(Gecoust.ad from Gecoust where Gecoust.Evrakno = 'STKGK2') as GPADfrom stok00 e where e.kod like 'SAC SIL%'--GROUP BY e.Gk_2If this is not, post us the structures of those two tables and sample data as well as expected output |
|
|
bandi
Master Smack Fu Yak Hacker
2242 Posts |
Posted - 2013-04-12 : 04:49:32
|
You can get quick response by posting respective forums... Refere these linkshttp://cs.pervasive.com/forums/p/13892/47794.aspx#47794http://cs.pervasive.com/search/SearchResults.aspx?q=Invalid+Row-count |
|
|
Kelapa
Starting Member
8 Posts |
Posted - 2013-04-12 : 04:58:12
|
quote: If this is not, post us the structures of those two tables and sample data as well as expected output
Thanks a lot for your effort, I handled the issue that I snuggled to handle. But I believe that I will get another issue soon while I get in some details script more.Here is the solvingSELECT e.Gk_2, f.adfrom Stok00 e LEFT OUTER JOIN Gecoust f on e.Gk_2 = f.kod where e.kod like 'SAC SIL%' and f.Evrakno = 'STKGK2' group by e.GK_2, f.ad |
|
|
bandi
Master Smack Fu Yak Hacker
2242 Posts |
Posted - 2013-04-12 : 05:40:35
|
quote: Originally posted by Kelapa
quote: If this is not, post us the structures of those two tables and sample data as well as expected output
Thanks a lot for your effort, I handled the issue that I snuggled to handle. But I believe that I will get another issue soon while I get in some details script more.Here is the solvingSELECT e.Gk_2, f.adfrom Stok00 e LEFT OUTER JOIN Gecoust f on e.Gk_2 = f.kod where e.kod like 'SAC SIL%' and f.Evrakno = 'STKGK2' group by e.GK_2, f.ad
WelcomeHere you can avoid duplicates by using DISTINCT keyword rather than GROUP BY ...SELECT DISTINCT e.Gk_2, f.adfrom Stok00 e LEFT OUTER JOIN Gecoust f on e.Gk_2 = f.kod where e.kod like 'SAC SIL%' and f.Evrakno = 'STKGK2'--Chandu |
|
|
|
|
|
|
|