Click here to Skip to main content
15,897,371 members
Home / Discussions / Database
   

Database

 
AnswerRe: Stored Proc & Web service Pin
Vimalsoft(Pty) Ltd29-Dec-08 22:40
professionalVimalsoft(Pty) Ltd29-Dec-08 22:40 
QuestionHelp in creat this Sql Pin
Mangore7527-Dec-08 23:14
Mangore7527-Dec-08 23:14 
AnswerRe: Help in creat this Sql Pin
Mycroft Holmes28-Dec-08 14:51
professionalMycroft Holmes28-Dec-08 14:51 
GeneralRe: Help in creat this Sql Pin
Mangore7529-Dec-08 5:27
Mangore7529-Dec-08 5:27 
QuestionHow to substring the following Pin
dabuskol27-Dec-08 19:47
dabuskol27-Dec-08 19:47 
AnswerRe: How to substring the following Pin
Wendelius27-Dec-08 22:00
mentorWendelius27-Dec-08 22:00 
AnswerRe: How to substring the following Pin
Khawar Abbas129-Dec-08 20:22
Khawar Abbas129-Dec-08 20:22 
QuestionOnly include the latest rows Pin
Tony Pottier27-Dec-08 9:48
Tony Pottier27-Dec-08 9:48 
Probably a dumb question, but I can't figure this out.

Suppose I have 2 tables:
ORDERS(id,cust_id,date,price)
CUSTOMERS(cust_id,name)

I want to know how much money the customer #3 spent, and how many orders he did, okay:
SELECT COUNT(*), SUM(price)
FROM orders
WHERE cust_id=3

So far so good, now I want to know this, but I want to narrow it down to the latest 50 orders he did (or to the latest x orders if x < 50), how can I do that?
SELECT COUNT(*), SUM(price)
WHERE cust_id=3
ORDER BY date DESC
LIMIT 50
doesn't work, because there's still only 1 row returned. I'm a bit clueless Confused | :confused:

Thanks for your help!
AnswerRe: Only include the latest rows Pin
Wendelius27-Dec-08 10:01
mentorWendelius27-Dec-08 10:01 
GeneralRe: Only include the latest rows Pin
Tony Pottier27-Dec-08 10:29
Tony Pottier27-Dec-08 10:29 
GeneralRe: Only include the latest rows Pin
Wendelius27-Dec-08 10:37
mentorWendelius27-Dec-08 10:37 
GeneralRe: Only include the latest rows Pin
Tony Pottier27-Dec-08 10:48
Tony Pottier27-Dec-08 10:48 
GeneralRe: Only include the latest rows Pin
Wendelius27-Dec-08 11:01
mentorWendelius27-Dec-08 11:01 
Question[Message Deleted] Pin
hatan8627-Dec-08 9:44
hatan8627-Dec-08 9:44 
AnswerRe: MS Access Database update error help Pin
Wendelius27-Dec-08 9:50
mentorWendelius27-Dec-08 9:50 
GeneralRe: MS Access Database update error help Pin
hatan8627-Dec-08 10:19
hatan8627-Dec-08 10:19 
GeneralRe: MS Access Database update error help Pin
Wendelius27-Dec-08 10:27
mentorWendelius27-Dec-08 10:27 
QuestionI want to discuss about a web project.Can I? Pin
R111927-Dec-08 3:41
R111927-Dec-08 3:41 
AnswerRe: I want to discuss about a web project.Can I? Pin
Colin Angus Mackay27-Dec-08 10:36
Colin Angus Mackay27-Dec-08 10:36 
GeneralRe: I want to discuss about a web project.Can I? Pin
Jon_Boy30-Dec-08 14:29
Jon_Boy30-Dec-08 14:29 
GeneralRe: I want to discuss about a web project.Can I? Pin
Colin Angus Mackay30-Dec-08 15:10
Colin Angus Mackay30-Dec-08 15:10 
GeneralRe: I want to discuss about a web project.Can I? Pin
Colin Angus Mackay30-Dec-08 15:14
Colin Angus Mackay30-Dec-08 15:14 
AnswerRe: I want to discuss about a web project.Can I? Pin
Colin Angus Mackay27-Dec-08 10:42
Colin Angus Mackay27-Dec-08 10:42 
AnswerRe: I want to discuss about a web project.Can I? Pin
Rob Graham28-Dec-08 5:31
Rob Graham28-Dec-08 5:31 
AnswerRe: I want to discuss about a web project.Can I? Pin
Jon_Boy30-Dec-08 14:25
Jon_Boy30-Dec-08 14:25 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.