473,943 Members | 16,059 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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_CREAT ED) and originating country(CARD_CO UNTRY_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_QUOTATIO N*0.667753)/100
END) AS ShortSea
FROM PO_ECOM.V_BOOKI NGS
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 1142
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
2502
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
372
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, buttons, etc) and are all of the same type of user object - just showing different data. In this case, each one is a "question" being presented that needs to be answered, and the requirement is to be able to show all the questions for a given...
0
1243
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 that can be made by an user interface. This application needs to run as an automatic process, so user intervention is not preferred.
3
1689
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 too basic for my needs. Or would I be best to continue to root around the internet and this newsgroup? I really would like a book I can refer to, however... To give a better idea as to the level I'm looking at.. - queries are generally not a...
10
14437
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 user to gain the required rights for execution (the external process needs to create a mailbox in Exchange, so it needs to be run as an Exchange Full Administrator-powered user). For the moment, I have tries using the Start() static method of the...
3
3116
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 of the website from 20 mn to 60 mn. I changed the timeout setting in IIS. Now the website itself doesn't time out, however after 20 mn, when I try to access a page that needs to connect to the database, I get the following error message
4
1632
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 executed after the Page_Load of the page. So we cannot catch this in the Page_Load of the page. So my question where in the page i will catch the exception thrown form the user control. I don't want any event to be raised from the user control.
12
6606
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 have added the new user to the database and have given the user access to the database for the app. But everytime I try and login using this users ID, I always get the error: Login failed for user Christian.Gaut If I login using my userid and...
0
1062
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 issue, but since most of y'all know asp.net as well, I'm sure someone can help :) Thanks .... Mythran Original Post Below ----------------------------------------------------------------- I have:
33
11898
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 (NT_AUTHORITY\SYSTEM). I understand that when the service starts, no user may be logged in, but that's ok, as the app I am monitoring can only be run by a logged in user. Do I need to use WMI to get the user context of Explorer.exe or is there a...
0
10143
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
11539
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
11303
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9866
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
8228
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6312
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4913
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4515
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3516
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.