473,396 Members | 1,792 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

New user needs help



Hi all

I am new to sql code and am not even sure i am posting this in the right
place but would be grateful for any assistance.

I am trying to write a sql query as follows:

I want to select data based on a route(OUTBOUND_ROUTE),
date(DATE_CREATED) and originating country(CARD_COUNTRY_ID). I have
another field call TOTAL_QUOTATION and my aim is to have one record
displayed for each date (7 dates in total which are the 7 days previous
to when user runs query) showing a total figure. I need to do a
calculation on TOTAL_QUOTATION whereby if CARD_COUNTRY_ID = "gb" then
divide total_quotation by 100 else multiply total_quotation by 0.667753
and then divide by 100 (this makes each total_quotation figure a £
value). So regardless of route and card_country_id i want each date to
show the £ total.

Here is my code

SELECT DATE_CREATED,
SUM(CASE CARD_COUNTRY_ID
WHEN 'GB'
THEN TOTAL_QUOTATION/100
ELSE (TOTAL_QUOTATION*0.667753)/100
END) AS ShortSea
FROM PO_ECOM.V_BOOKINGS
WHERE(OUTBOUND_ROUTE = 'DOVECALA'
OR OUTBOUND_ROUTE = 'CALADOVE')
AND (DATE_CREATED LIKE to_DATE(SYSDATE -7, 'DD-MON-YYYY')
OR DATE_CREATED LIKE TO_DATE(SYSDATE -6, 'DD-MON-YYYY')
OR DATE_CREATED LIKE TO_DATE(SYSDATE -5, 'DD-MON-YYYY')
OR DATE_CREATED LIKE TO_DATE(SYSDATE -4, 'DD-MON-YYYY')
OR DATE_CREATED LIKE TO_DATE(SYSDATE -3, 'DD-MON-YYYY')
OR DATE_CREATED LIKE TO_DATE(SYSDATE -2, 'DD-MON-YYYY')
OR DATE_CREATED LIKE TO_DATE(SYSDATE -1, 'DD-MON-YYYY'))
GROUP BY DATE_CREATED
what i am expecting as output is something like

29/06/04 30,000
30/06/04 10,000

instead i am getting something like

29/06/04 15
29/06/04 155.55555
etc

From this i can see that the code is running my calculation but is not
adding all the totals together by date.

I would be grateful for any help

thanks
Michelle

*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 20 '05 #1
1 1119
This is a Microsoft SQL Server group but your query isn't SQL Server code.
It looks more like Oracle. If this is an Oracle question you should get more
help in comp.databases.oracle.server.

Without seeing some sample data it's difficult to determine where the
problem is. The best way to get help is to post some code to reproduce the
problem: a CREATE TABLE statement for your table and a few INSERT statements
of sample data, then explain what result you want from that sample data.

Hope this helps.

--
David Portas
SQL Server MVP
--
Jul 20 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

26
by: Simon | last post by:
I'm doing a survey. When do you think GNU/Linux will be ready for the average Joe? What obstacles must it overcome first?
3
by: RCCNH | last post by:
I am creating a Windows application using C# in .NET. In one of the windows, I have to show a scrollable list of user objects. Those user objects contain various controls themselves (textbox,...
0
by: gertjan.nospam | last post by:
Hello, I hope you can help me with this issue. I am trying to build an application in C# that converts text from XML with an XSL to a HTML file and prints it according to some printersettings...
3
by: Martin Lacoste | last post by:
Wondering if people have suggestions as to good reference sources for Access 2000 for an (almost..) intermediate user? It appears as though books along the lines of 'Access for Dummies' are way...
10
by: Sorin Dolha [MCSD .NET] | last post by:
I would like to start a process from C# code as another user. The C# code is executed as the ASPNET user because it relies in a Web Page class, and I would like that the process will run as another...
3
by: Maellic | last post by:
Hi, The website I am working on is built with ASP.NET and connects to a SQL Server 2000 database. The web server and database are on the same machine. I have recently tried to modify the timeout...
4
by: Prince Mathew | last post by:
Hi All, I have a requirement. I am throwing an exception from the Page_Load of my user control I want to catch this in my container page. Is this possible? The Page_Load of user control is...
12
by: Michael | last post by:
Please Help me. I've got a .Net 2003 program that attaches to a SQL Server machine and I'm getting the above error when a user tries to log in. The SQL server is setup to use Windows Auth. and I...
0
by: Mythran | last post by:
I apologize for the need to x-post this thread. The original thread is getting pretty old and no replies in microsoft.public.dotnet.framework.aspnet. Also, I'm aware that this isn't a C# only...
33
by: JamesB | last post by:
I am writing a service that monitors when a particular app is started. Works, but I need to get the user who is currently logged in, and of course Environment.UserName returns the service logon...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.