| |

VerySource

 Forgot password?
 Register
Search
View: 1673|Reply: 11

The problem of sql statement, everyone helps to see.

[Copy link]

1

Threads

3

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-1-6 11:10:01
| Show all posts |Read mode
select title, count (*) as c, defaultpicurl from PE_article where articleid> = 122580 and articleid <= 123583 and deleted <>-2 group by title having count (*)> 1
Microsoft OLE DB Provider for SQL Server error '80040e14'

The column 'PE_article.DefaultPicUrl' is not valid in the select list because the column is neither included in the aggregate function nor in the GROUP BY clause.

How to change this, I do n’t want to use defaultpicurl in group by
But I want to be able to read the value of the defaultpicurl field.
Reply

Use magic Report

0

Threads

322

Posts

115.00

Credits

Newbie

Rank: 1

Credits
115.00

 China

Post time: 2020-1-6 12:30:01
| Show all posts
How to change this, I do n’t want to use defaultpicurl in group by
But I want to be able to read the value of the defaultpicurl field.
=============

how can that be?
Reply

Use magic Report

1

Threads

3

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

 Author| Post time: 2020-1-6 12:48:01
| Show all posts
rs.open "select title, count (*) as c from PE_article where articleid> = 122580 and articleid <= 123583 and deleted <>-2 group by title having count (*)> 1", conn, 1,1
 
This is reading the title field with duplicate records.
Now when I read the record, I can use rs ("title") to get the value of this field.
Can I also read the value of another field using rs ("aabc")? Can't this be achieved?
Reply

Use magic Report

0

Threads

322

Posts

115.00

Credits

Newbie

Rank: 1

Credits
115.00

 China

Post time: 2020-1-6 13:03:01
| Show all posts
No, if you add a field, you must press this field
group by.
Reply

Use magic Report

0

Threads

322

Posts

115.00

Credits

Newbie

Rank: 1

Credits
115.00

 Unknown

Post time: 2020-1-6 13:12:01
| Show all posts
for example:
Title defaultpicurl
A 11
A 22

If you just press TITLE group by, you also want to display the defaultpicurl

Does it show 11 or 22?
Reply

Use magic Report

0

Threads

25

Posts

21.00

Credits

Newbie

Rank: 1

Credits
21.00

 China

Post time: 2020-1-6 13:24:01
| Show all posts
The columns specified in the group by clause must be included in the select list
Reply

Use magic Report

0

Threads

15

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 China

Post time: 2020-1-6 13:27:01
| Show all posts
It's not easy to write code so late. . .
Reply

Use magic Report

0

Threads

25

Posts

21.00

Credits

Newbie

Rank: 1

Credits
21.00

 China

Post time: 2020-1-6 13:54:01
| Show all posts
I'm used to it. I can't sleep early now.
Reply

Use magic Report

1

Threads

3

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

 Author| Post time: 2020-1-6 14:48:01
| Show all posts
Then there is no way.
Reply

Use magic Report

0

Threads

41

Posts

13.00

Credits

Newbie

Rank: 1

Credits
13.00

 China

Post time: 2020-1-22 07:36:01
| Show all posts
select title, count (*) as c, max (defaultpicurl) as defaultpicurl from PE_article where articleid> = 122580 and articleid <= 123583 and deleted <>-2 group by title having count (*)> 1
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list