16,008,490 members
Sign in
Sign in
Email
Password
Forgot your password?
Sign in with
home
articles
Browse Topics
>
Latest Articles
Top Articles
Posting/Update Guidelines
Article Help Forum
Submit an article or tip
Import GitHub Project
Import your Blog
quick answers
Q&A
Ask a Question
View Unanswered Questions
View All Questions
View C# questions
View C++ questions
View Javascript questions
View Visual Basic questions
View .NET questions
discussions
forums
CodeProject.AI Server
All Message Boards...
Application Lifecycle
>
Running a Business
Sales / Marketing
Collaboration / Beta Testing
Work Issues
Design and Architecture
Artificial Intelligence
ASP.NET
JavaScript
Internet of Things
C / C++ / MFC
>
ATL / WTL / STL
Managed C++/CLI
C#
Free Tools
Objective-C and Swift
Database
Hardware & Devices
>
System Admin
Hosting and Servers
Java
Linux Programming
Python
.NET (Core and Framework)
Android
iOS
Mobile
WPF
Visual Basic
Web Development
Site Bugs / Suggestions
Spam and Abuse Watch
features
features
Competitions
News
The Insider Newsletter
The Daily Build Newsletter
Newsletter archive
Surveys
CodeProject Stuff
community
lounge
Who's Who
Most Valuable Professionals
The Lounge
The CodeProject Blog
Where I Am: Member Photos
The Insider News
The Weird & The Wonderful
help
?
What is 'CodeProject'?
General FAQ
Ask a Question
Bugs and Suggestions
Article Help Forum
About Us
Search within:
Articles
Quick Answers
Messages
Comments by Necron8 (Top 10 by date)
Necron8
13-Sep-13 4:48am
View
Minor modification to your query
the order by WinRation Desc and LMIT1 must be after the 't'
since the field is on the outer level of the query.
This isn't right though, since it gets each game played individually user (if i remove the limit)
Ex:
Game Name userName gamesWon gamesPlayed winRatio
Monster Hunt John 0 1 0
Monster Hunt John 1 1 1
Fishing Kate 1 1 1
Fishing John 1 1 1
Fishing John 1 1 1
Thanks to all those who are helping
Necron8
12-Sep-13 10:58am
View
For the first query, I had to name the select as a different table name since I had to retrieve each and every user prediction won / lost, so one is solved. I have commented regarding the user stats above but couldn't get it to work. Can you help me and see the above comment? Thanks!
Necron8
12-Sep-13 10:54am
View
Hi there guys, solved the first query:
SELECT u.userID, u.userName, u.userImageUrl, l.leagueName ,
COUNT(g.gameId) AS predTotal,
(SELECT COUNT(gw.gameId) FROM games AS gw WHERE gw.gameResultOut = 1 AND gw.gameWon = 1) AND gw.gameUserID = u.user_id AS gamesWon,
(SELECT COUNT(gl.gameId) FROM games AS gl WHERE gl.gameResultOut = 1 AND gl.gameWon = 0) AND gl.gameUserID = u.user_id AS gamesLost,
ub.balance
FROM games AS g
LEFT JOIN league AS l ON l.leagueId = g.gameLeagueId
LEFT JOIN user AS u ON u.user_id = g.gameUserID
LEFT JOIN user_balance AS ub ON ub.userId = u.userID
WHERE l.leagueId = 4
GROUP BY u.userId
ORDER BY ub.balance DESC
I forgot to change the names of the select to get the unique user predictions won/lost count.
As regarding to statistics, I'm trying to get the following result but I'm getting gamesWon column undefined:
Trying to get a ratio for the number of games won per user:
SELECT
g.gameName,
(SELECT COUNT(gw.gameId) FROM games gw WHERE g.gameResultOut = 1 AND g.gameWon = 1 AND gw.gameUserID = u.user_id) AS gamesWon,
COUNT(g.gameId) AS gamesPlayed,
(gamesWon / gamesPlayed) AS winRatio
FROM
games g
INNER JOIN user u ON u.user_id = g.gameUserID
GROUP BY g.gameId, u.user_id
ORDER BY winRatio DESC
LIMIT 1
Necron8
2-Mar-12 14:41pm
View
I can't seem to make it work ;/
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'as 'Total Class Hours'), min(sa.studentName) as 'studentName', SUM(CASE WHEN sa.' at line 1
SELECT SUM(a.att_duration as 'TotalClassHours'), min(sa.studentName) as 'studentName', SUM(CASE WHEN sa.sa_type = 'P' THEN att_duration end) AS 'Total Hours Attended' FROM attendance AS a LEFT OUTER JOIN student_attendance AS sa ON sa.attendanceID = a.attID LEFT OUTER JOIN periods AS p ON p.perioID = a.attID LEFT OUTER JOIN students AS s on s.studentID = sa.studentID WHERE NOT sa.sa_type = 'N/A' AND a.att_courseID = '1' AND a.att_periodID = '8' GROUP BY sa.studentID
Do I need to change some of the tables in this query or? everything seems fine. I tried changing a.att_duration to attendance.attendance_duration and all the others but the same error occurs. What should I do? Sry for being such a noob at this ;/
Necron8
28-Feb-12 15:10pm
View
Currently, what I did was to make a while loop to get the Period Start Date and Period End date and also the dates between. From the while loop, I search the attendance and get the students associated to that attendance.
If I have 3 attendances on a certain date (ex 26/2/2012), the query gives you 3 sets of students.
What I want is one set of student with the lesson start/end and attendance as I described above.
How could this be done?
Necron8
24-Feb-12 15:29pm
View
Yes exactly!, I tried to explain the algorithm above, but don't know what query to use. You would be the best & awesomest if you could explain to me what is needed!
The user selects the Course for which he / she wants the attendance while also selecting the period no
So:
Dropdown: SELECT PERIOD
Dropdown: SELECT COURSE
Will return what you said - the stuff needed - where the period is ex say 1 (Period no 1 for example has a START DATE of 1/1/2012 and END DATE of 28/1/2012
) and Course is Engineering
THANKS!
Necron8
6-Feb-12 12:47pm
View
Yeah I think it's a fair deal. So what languages are being used that are better then PHP?
Thanks for the tip :)
Necron8
25-Dec-11 6:54am
View
Haha sure will. This jformer is killing me! Happy Christmas and a new Year to All! :)
Necron8
24-Dec-11 5:52am
View
Thanks man!. I've been trying on getting this to work for hours and seeing such a simple solution makes me laugh or cry -_-.
Thanks a lot!
Necron8
24-Dec-11 5:51am
View
Ah ok, Thanks sry about that
Show More